通过批处理/CMD刷新Internet选项

3
我编写了一个批处理程序,使用以下代码启用和禁用Internet选项中的代理使用:
[Enable]
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f 

[Disable]
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f 

这段代码运行良好,但是为了应用更改并使用代理连接到互联网,我必须关闭并重新打开浏览器。有没有一种方法可以在不这样做的情况下应用代理。
我已经尝试过“ipconfig /renew”和“ipconfig /release”。我还尝试禁用并启用本地连接。
如果知道通过批处理/cmd或其他程序连接到代理且没有此问题的另一种方法,那将非常有帮助。
3个回答

0

我不使用代理,所以对我来说这是空白的,但这个命令似乎是你想要的。

netsh winhttp ?

显示有关设置代理等的帮助信息。

这是有关设置代理的帮助信息。

C:\Users\User>netsh winhttp set proxy ?

Usage:  set proxy [proxy-server=]<server name> [bypass-list=]<hosts list>

Parameters:

  Tag              Value
  proxy-server  -  proxy server for use for http and/or https protocol
  bypass-list   -  a list of sites that should be visited bypassing the
                   proxy (use "<local>" to bypass all short name hosts)

Examples:

  set proxy myproxy
  set proxy myproxy:80 "<local>;bar"
  set proxy proxy-server="http=myproxy;https=sproxy:88" bypass-list="*.foo.com"

我以前尝试过使用这个,但对我没有起作用。我会继续尝试一下,看看能否让它起作用。 - Peter

0

要在命令行中应用更改以启用或禁用Internet Explorer中的代理,有两种方法。

第一种方法:
1- 以管理员身份运行命令行
2- 在更改注册表之前终止Internet Explorer

   Taskkill /F /IM iexplore.exe 

第三种方法
1- 以管理员身份运行命令行
2- 像你在问题中所做的那样更改代理启用/禁用
3- 从注册表中更改代理启用或禁用,就像你在问题中所做的那样。

第二种方法
1- 以管理员身份运行命令行
2- 像你在问题中所做的那样更改代理启用/禁用
3- 终止 Windows Explorer,然后在更改注册表后重新打开。

taskkill /F /IM explorer.exe && start /w /b explorer.exe

0

这是一种粗暴的方法,但在Win 10上有效。

我们必须连接到一个自动禁用Internet选项 - 连接选项卡并设置代理的VPN。通过以下方式解决,使用.bat文件:

REM Andrea & Giulio. Uno Due Sei Nove!
REM Enable Internet Option Connection Tab
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Control Panel" /v ConnectionsTab /t REG_DWORD /d 0 /f

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

REM Start IE to refresh values, sleep & kill
START /d "" IEXPLORE.EXE www.google.com
TIMEOUT 10
TASKKILL /IM iexplore.exe /F

TIMEOUT 10

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接