0

In a batch script, I am updating a registry value with the REG command to disable the manual proxy.

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f

However, this does not take effect until I open the proxy settings page in Windows (Start Menu > Change Proxy Settings). All I have to do is open the page and the property gets updated correctly.

Is there any way to reload/update this setting without opening the network settings?

JayD
  • 23
  • 1
  • 9
  • Have you tried rebooting the machine ? If so you may reboot it in the batch file as well, and if you’re on a domain I suggest you make use of the group policy and maybe if you change the registers values whole the pc is signed out ( remotely ) then the user who signs in gets the settings. – Elie Jun 21 '18 at 14:10
  • The registry is updated when you run the command, the program has no clue until you open that settings window and it checks the registry for that setting. – Moab Jun 21 '18 at 14:19
  • @Elie No, I've not tried rebooting and although I'm quite confident that would sufficiently update the variable, it is not really an option for me either. Group policy won't work because I'm only a local admin. – JayD Jun 21 '18 at 15:13
  • @Moab Yes, that is essentially my question: *how to update "the program" from within my batch script?* I've edited the misleading title. – JayD Jun 21 '18 at 15:15

4 Answers4

1

This link suggests that it cannot be done: https://superuser.com/a/944980/916597.

Unfortunately, there is no easy way. As you’ve noticed, you’re missing the magic “read those settings now” command:

Note that in the link, the answer mentions that there is possibly a way to do it in PowerShell, but that doesn't answer this question. If it interests you, though, go check it out.

JayD
  • 23
  • 1
  • 9
0

I had the same issue when enabling/disabling a proxy using a vbs script.

I just added this:

Shell.run "ms-settings:network-proxy"

WScript.Sleep 1000

Shell.Run "taskkill /f /im SystemSettings.exe", , True

it opens the proxy settings, waits 1 second and then closes it. This will ensure that your proxy changes are working.

0

I have created simple CLI tool which force reload IE proxy settings. It calls WININET.DLL InternetSetOption function as described here: https://superuser.com/a/944980/916597

Download it from here: https://gofile.io/?c=ol4zE7

Tested on W7 and W10.

0

Need to force system settings update, iexplore do it for you:

REM Enable-Disable System Proxy in one file

@echo off

SET home_key="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

FOR /F "tokens=3" %%L IN ('reg query %home_key% /v ProxyEnable' ) DO SET currentProxy=%%L

IF %currentProxy% == 0x1 goto turnoff

IF %currentProxy% == 0x0 goto turnon

:turnoff

reg add %home_key% /v ProxyEnable /t REG_DWORD /d 0 /f

SET proxy="Proxy disabled"

goto EOF

:turnon

reg add %home_key% /v ProxyEnable /t REG_DWORD /d 1 /f

SET proxy="Proxy enabled"

goto EOF

:EOF REM Restart Internet Explorer to changes take efect

start /w /b iexplore.exe

timeout 2 /nobreak

taskkill /f /im iexplore.exe

echo %proxy%