Обновлено:
Опубликовано:
Что такое реестр Windows простыми словами.
Большинство команд лучше выполнять, запустив командную строку от имени администратора. Для этого найдите ее по ключу cmd — кликните по файлу правой кнопкой мыши — выберите Запустить от имени администратора. Или в Windows 10 правой кнопкой по Пуск — Командная строка (администратор).
Чтение данных
Добавление параметров
Удаление
Редактирование
Импорт
Описание всех команд
Выборка (query)
reg query HKLM\Software\Microsoft
* в данном примере будет выведен на экран список веток, которые находятся в HKLM\Software\Microsoft
Если в пути встречается пробел, необходимо весь путь поместить в кавычки, например:
reg query «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings»
Чтобы вывести все вложенные ветки, запускаем команду с параметром /s:
reg query «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings» /s
Добавление (add)
Синтаксис:
reg add <Ключ> /v <Параметр> /t <Тип> /d <Значение>
Например, добавим настройки использования прокси-сервера для браузера Internet Explorer:
reg add «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings» /v ProxyEnable /t REG_DWORD /d 1
reg add «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings» /v ProxyServer /t REG_SZ /d «192.168.0.15:3128»
reg add «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings» /v ProxyOverride /t REG_SZ /d «<local>»
* где первая команда включает использование прокси-сервера; вторая прописывает использовать прокси с IP-адресом 192.168.0.15 и портом 3128; третья указывает не использовать прокси для локальных адресов.
Удаление (delete)
Синтаксис:
reg delete <Ключ> /v <Параметр>
Например, чтобы удалить одну из ранее созданной настройки, вводим следующую команду:
reg delete «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings» /v ProxyEnable /f
Чтобы удалить всю ветку с ее параметрами и значениями, вводим такую команду:
reg delete «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings» /va /f
Редактирование
Для редактирования значения нужно выполнить команду на добавление. Если ключ уже существует, команда заменить значение на новое:
reg add «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings» /v ProxyEnable /t REG_DWORD /d 0 /f
* в данном примере будет изменено значение ключа ProxyEnable на 0 (или создан с таким значением); ключ f указывает на замену значения без вывода подтверждения.
Импорт
Во многих случаях проще выполнить импорт из файла, кликнув по нему дважды. Но, иногда необходимо выполнить импорт из командной строки:
reg import <путь к файлу>
Например:
reg import C:\Temp\import_proxy_settings.reg
* в данном примере мы импортировали настройки из файла import_proxy_settings.reg, который находится в каталоге C:\Temp\.
Краткое описание всех операций
В данной таблице приведены все возможные операции над коандой REG.
Операция | Описание |
---|---|
REG QUERY | Делает выборку ключей, параметров и значений |
REG ADD | Добавляет новую запись (параметр, ключ, значение) |
REG DELETE | Удаляет одну или несколько записей |
REG COPY | Копирует данные из одной ветки в другую |
REG SAVE | Сохраняет ветку со всеми параметрами и значениями в файл |
REG RESTORE | Восстанавливает ветку и данные из файла |
REG LOAD | Загружает данные в указанную ветку |
REG UNLOAD | Выгружает данные из указанной ветки |
REG COMPARE | Сравнивает две ветки |
REG EXPORT | Экспортирует все подразделы и параметры в файл .reg |
REG IMPORT | Импортирует все подразделы и параметры из файла .reg |
REG FLAGS | Показывает и устанавливает флаги для ветки |
Подробное описание всех ключей можно увидеть, введя команду reg <операция> /?
Например: reg add /?
Была ли полезна вам эта инструкция?
Да Нет
My requirement is that I need to change the value of a registry
in particular this key "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Value=ProxyEnable
The REG_DWORD
(0
or 1
) needs to be switched.
i.e
SWITCH:
IF proxy ENABLED then DISABLE
IF proxy DISABLED then ENABLE
To Enable
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
To Disable
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
.
@echo off
setlocal
set key="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
set value=ProxyEnable
set newdata=0
for /f "tokens=2* skip=3" %%a in ('reg query %key% /v %value%') do (
set type=%%a
set data=%%b
)
echo %data% | find /i "%newdata%" > nul
if %errorlevel% equ 0 (echo %newdata% already present
) else (
echo reg add %key% /v %value% /t %type% /d %newdata% /f
)
this is the code so far, unable to modify it.
asked Jan 20, 2015 at 20:27
1
To toggle/switch the value from 1 to 0 and 0 to 1, some simple maths helps simplify things: set /a newdata=1-data
Here’s how I would do it:
@echo off
setlocal
set key="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
set value=ProxyEnable
for /f "tokens=2* skip=2" %%a in ('reg query %key% /v %value%') do (
set data=%%b
)
set /a newdata=1-data
reg add %key% /v %value% /d %newdata% /f
answered Jan 21, 2015 at 12:32
Scott CScott C
1,6601 gold badge11 silver badges18 bronze badges
2
I thing you have to use skip=2
:
@echo off
set key="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
set "value=ProxyEnable"
for /f "tokens=2* skip=2" %%a in ('reg query %key% /v %value%') do call:Treat %%a %%b
exit/b
:Treat
echo %2 | find /i "1" && echo already present || reg add %key% /v %value% /t %1 /d 1 /f
If you want to disable it if present just replace the echo already present
by :
reg add %key% /v %value% /t %1 /d 0 /f
answered Jan 20, 2015 at 21:14
SachaDeeSachaDee
9,2653 gold badges24 silver badges34 bronze badges
@echo off
setlocal
set key="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
set value="ProxyEnable"
set newdata=0x0
For /f "tokens=2,3 skip=2 delims= " %%a in ('reg query %key% /v %value%') do (
set type=%%a
set data=%%b
)
echo %data% | find /i "%newdata%" > nul
if %errorlevel% equ 0 (echo %data% already present & reg add %key% /v %value% /t %type% /d 1 /f
) else (
echo %data% already present & reg add %key% /v %value% /t %type% /d 0 /f
)
answered Oct 11, 2018 at 23:49
holloposthollopost
5699 silver badges28 bronze badges
If I edit Proxy Settings through the Control Panel, the settings are stored in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable
and ...\ProxyServer
. These settings are of course not used when running as a service under LOCAL SYSTEM
.
So I tried setting ProxyEnable
and ProxyServer
under HKEY_USERS\S-1-5-18\...
(as well as HKEY_USERS\.DEFAULT\...
and all the other users on the system), but that does not work.
How do I set the proxy settings for the LOCAL SYSTEM
user?
asked Jul 2, 2009 at 10:42
It is actually the value in Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\DefaultConnectionSettings
that is used.
Since that is not easily modified, you can modify the proxy settings for a user, export the registry key, modify the path in the exported file to HKEY_USERS\S-1-5-18
and reimport it.
030
5,94113 gold badges68 silver badges110 bronze badges
answered Jul 2, 2009 at 10:51
Rasmus FaberRasmus Faber
6631 gold badge6 silver badges9 bronze badges
3
First, run cmd
as administrator to open a command prompt.
Command to copy proxy settings of current user to WinHttp:
netsh winhttp import proxy source =ie
To reset the proxy to default settings:
netsh winhttp reset proxy
To show proxy settings of current user:
netsh winhttp show proxy
answered Jun 4, 2014 at 14:54
TomazZTomazZ
1471 silver badge2 bronze badges
2
Another way, albeit much messier, is to use psexec to open a command prompt running as LOCAL SYSTEM, then from that open iexplore.exe, modify the settings appropriately.
answered Aug 13, 2013 at 15:02
RoryRory
4825 gold badges12 silver badges22 bronze badges
1
The Same thing can be done much easier in this way-
& C:\windows\System32\bitsadmin.exe /Util /SetIEProxy LocalSystem Manual_proxy http://<proxyserver>:<proxy port> "<Any bypasses to be added>"
answered Oct 13, 2017 at 7:18
Reg add «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings» /v «ProxyEnable» /t REG_DWORD /d «0» /f
Reg add «HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings» /v «ProxyServer» /t REG_SZ /d «http://procycorp.bac:80» /f
answered Oct 31, 2015 at 6:05
2
You might want to try using ProxyCFG.EXE, which sets the proxy for any WinHTTP calls.
answered Aug 13, 2009 at 5:12
2
You must log in to answer this question.
Not the answer you’re looking for? Browse other questions tagged
.
Not the answer you’re looking for? Browse other questions tagged
.
I needed to check the proxy settings on a Windows 8 system that appeared
to have been infected by malware that configured the system to use
a proxy server running on the system that was installed by the malware. If
you wish to view the proxy settings that will be used by Internet
Explorer or by any application that will rely upon the system proxy
settings for its own proxy use, the proxy server settings can be checked
in Internet Explorer 11, and by a similar process in recent versions before
it, by the following steps, either from within Internet Explorer or from
a command prompt:
From within Internet Explorer
-
Click on the gear icon in the upper, right-hand corner of the Internet Explorer
window. - Select Internet options.
-
Click on the Connections tab.
-
Click on LAN settings.
-
If «Use a proxy server for your LAN» has a check in the checkbox, then a proxy
server has been set. Click on the Advanced button to see the details for
the proxy server.
In the example above, I can see that the proxy server in use is running
on the local loopback address for the system, i.e., 127.0.0.1, so the proxy
server software is running on the system itself and is handling both HTTP
and HTTPS connections. It is listening on port 55833.
From a command prompt
Alternatively, you can also view the proxy server settings by querying
the
Windows Registry
from a command prompt as shown below:
C:\>reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings ProxyEnable REG_DWORD 0x1 C:\>reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings ProxyServer REG_SZ http=127.0.0.1:55833;https=127.0.0.1:55833
The first reg query
command shows that ProxyEnable
is set to 1
, since 0x1
indicates that the value
is hexadecimal 1, which is the same as decimal 1, indicating a proxy
server is being used for the currently logged in user under whose
account the command was run. If the value was zero, then no system-wide
proxy server is in use. The second reg query
command
shows the IP address for the proxy server. In this case the proxy server
has been set up by malware on the system to route HTTP and HTTPS traffic
through a proxy server it has installed on the system.
On another system configured to use
a SOCKS proxy server set up via a
PuTTY SSH connection, the same reg query command shows the following:
C:\>reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings ProxyServer REG_SZ socks=127.0.0.1:1080
Again, the 127.0.0.1
address indicates the SOCKS proxy server
is running on the system on which the command was issued. In this case
the SOCKS proxy server is listening on port 1080.
If I wanted to change the proxy server settings so that any browser using
the system-side proxy server setting would no longer use the proxy server,
I could change the value of ProxyEnable
in the Windows registry
to be zero with the following reg add
command:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet
Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
The /d
followed by a zero specifies that the data to assign to
the registry ValueName, which was specified as ProxyEnable
by the /v
, is a zero. The /t
specifies that the
data type for the registry value is REG_DWORD
and the
/f
forces an overwrite of the current value without a prompt
appearing asking if you are sure you want to overwrite it. Without the
/f
, a window will open asking for confirmation of the replacement
of the current value in that registry location.
The value for ProxyServer
in the registry
remains the same, but browsers will no longer use the proxy.
C:\>reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f The operation completed successfully. C:\>reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings ProxyServer REG_SZ socks=127.0.0.1:1080 C:\>reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings ProxyEnable REG_DWORD 0x0
If you wished to enable the use of the proxy server agin, you could
issue the same reg add
command, but with /d 1
, instead
of /d 0
.
Note: if you change the proxy server setting within Google Chrome and
leave Chrome open when you change the value of ProxyEnable
to
zero or one with the reg add
command, you will need to get Chrome
to check the setting again by going through the
steps to view the proxy
server setting in Chrome or close and reopen Chrome.
Running
show-firefox-proxy-setting.bat on the system that was configured to
use an HTTP and HTTPS proxy listening on port 55833, as noted in
Finding the
proxy setting for Firefox from a command line, showed the following,
since it was configured to use the system proxy settings:
C:\Users\Public\Documents>show-firefox-proxy-setting.bat ---------- C:\USERS\JDoe\APPDATA\ROAMING\MOZILLA\FIREFOX\PROFILES\L7FNKEJA.DEFAULT\PREFS.JS
I.e., no proxy information was displayed. If it had been configured for
«manual proxy configuration» with 127.0.0.1 for both the HTTP Proxy and
SSL Proxy setting with port 55833 for both, it would have shown the
following:
C:\Users\Public\Documents>show-firefox-proxy-setting.bat ---------- C:\USERS\JDoe\APPDATA\ROAMING\MOZILLA\FIREFOX\PROFILES\L7FNKEJA.DEFAULT\PREFS.JS user_pref("network.proxy.http", "127.0.0.1"); user_pref("network.proxy.http_port", 55833); user_pref("network.proxy.ssl", "127.0.0.1"); user_pref("network.proxy.ssl_port", 55833); user_pref("network.proxy.type", 1);
I.e., the proxy server setting information displayed only applies to a
«manual proxy configuration» for Firefox.
Running the batch file on the system configured to use the SOCKS proxy where
Firefox was configured to use a «manual proxy configuration», showed the
following:
C:\>show-firefox-proxy-settings.bat ---------- C:\USERS\Joan\APPDATA\ROAMING\MOZILLA\FIREFOX\PROFILES\W9XPP5JC.D EFAULT\PREFS.JS user_pref("network.proxy.socks", "127.0.0.1"); user_pref("network.proxy.socks_port", 1080); user_pref("network.proxy.type", 1);
When Firefox is configured for «No proxy», it will show something similar
to the following:
C:\>show-firefox-proxy-settings.bat ---------- C:\USERS\Joan\APPDATA\ROAMING\MOZILLA\FIREFOX\PROFILES\W9XPP5JC.D EFAULT\PREFS.JS user_pref("network.proxy.type", 0);
I.e., it will show user_pref("network.proxy.type", 0);
.
If you wish to check the proxy server setting for an account on the
system other than the one under which you are currently logged in, you can
specify the Security Identifier (SID) for the account, instead of
HKCU
as shown below.
C:\>reg query "HKEY_USERS\S-1-5-21-3084690208-3888753220-1328190815-1115\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v P roxyEnable HKEY_USERS\S-1-5-21-3084690208-3888753220-1328190815-1115\Software\Microsoft\Win dows\CurrentVersion\Internet Settings ProxyEnable REG_DWORD 0x1
You can determine the SID for an account from the command line by
using the VBScript determine-sid script as shown below:
C:\Users\Public\Documents>cscript /nologo determine-sid.vbs Sue Onda Userid: Sue Computer Name/Domain: Onda SID: S-1-5-21-2441191556-19154564-1365248798-1001
The script must be run from an administrator account. The user account
name and the name of the computer, since the script can also query remote
computers, can be specified on the command line. E.g., in the case above
the username is «Sue» and the computer name is «Onda». If they aren’t specified
on the command line, a window will appear prompting for both.
Я хочу установить прокси-сервер через командную строку, первое, что я выяснил, это то, что вы должны выполнить командную строку с правами администратора. Тогда базовым набором прокси будет:
netsh winhttp set proxy SERVER:PORT
Это работает хорошо, но я также хочу добавить логин. Как вы можете видеть, я попытался использовать netsh- > winhttp, однако руководство ничего не говорит о части входа, поэтому я просто попробовал:
netsh winhttp set proxy user:[email protected]:PORT
Это, к сожалению, не работает. Возможно ли достичь чего-то подобного в netsh- > winhttp?
Если да, то как? Если нет = > какие команды окон следует выполнять?
Или это легче ̶a̶c̶h̶i̶e̶v̶e̶a̶b̶l̶e̶ через некоторые ̶W̶i̶n̶d̶o̶w̶s̶A̶P̶I̶ ̶ (например, с помощью C/C + + ̶ ̶) ̶? ̶
Спасибо за помощь, пожалуйста, не стесняйтесь задавать любые вопросы, если что-то неясно.
ИСПОЛЬЗОВАНИЕ: Windows 7, cmd.exe, netsh- > winhttp
EDIT: Это похоже на способ С++: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383144(v=vs.85).aspx, но лучший способ для С++ — это пойти следующим образом: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385384(v=vs.85).aspx#general_option, поэтому оставшийся вопрос заключается в том, как добиться этого в командной строке в целом (или даже лучше командной строки- > netsh- > winhttp)?
Ответ 1
Если вы используете среду Microsoft Windows, вы можете установить переменную с именем HTTP_PROXY
, FTP_PROXY
или HTTPS_PROXY
в зависимости от требования.
Я использовал следующие настройки, позволяющие моим командам в командной строке Windows использовать прокси-сервер браузера для доступа в Интернет.
set HTTP_PROXY=http://proxy_userid:[email protected]_ip:proxy_port
Параметры справа должны быть заменены фактическими значениями.
Как только переменная HTTP_PROXY
установлена, все наши последующие команды, выполняемые в командной строке Windows, смогут получить доступ к интернету через прокси вместе с предоставленной аутентификацией.
Кроме того, если вы хотите использовать ftp и https для использования того же прокси-сервера, вам также могут понравиться следующие переменные среды.
set FTP_PROXY=%HTTP_PROXY%
set HTTPS_PROXY=%HTTP_PROXY%
Ответ 2
IE может устанавливать прокси-серверы для имени пользователя и пароля, поэтому, возможно, его установить, а импорт работает
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d name:port
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyUser /t REG_SZ /d username
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyPass /t REG_SZ /d password
netsh winhttp import proxy source=ie
Ответ 3
На мой взгляд, лучший способ обойти это (и многие другие ситуации) — использовать cntlm, который является локальным прокси-сервером без аутентификации, который указывает на удаленный прокси-сервер аутентификации. Затем вы можете просто установить WinHTTP, чтобы он указывал на локальный CNTLM (обычно localhost: 3128), и вы можете настроить сам CNTLM, чтобы он указывал на удаленный прокси-сервер аутентификации. У CNTLM есть опция «обнаружения волшебного NTLM-диалекта», которая генерирует хэши паролей, которые нужно поместить в файлы конфигурации CNTLM.
Ответ 4
CMD
Туннелируйте весь свой интернет-трафик через прокси socks:
netsh winhttp set proxy proxy-server="socks=localhost:9090" bypass-list="localhost"
Просмотр текущих настроек прокси:
netsh winhttp show proxy
Очистить все настройки прокси-сервера:
netsh winhttp reset proxy