Dex*_*ave 17 windows batch-file internet-options
在Windows中,我想使用批处理脚本禁用" Internet选项"中的"代理服务器"设置.我可以使用什么命令来执行此操作?
如果不确定我指的是什么,请参阅
Internet Properties > Connections > LAN Settings >Proxy Server
Run Code Online (Sandbox Code Playgroud)
谢谢
PA.*_*PA. 19
它在[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]下的注册表中
您可以REG在BAT中使用该命令,也可以准备几个.REG文件来自动执行更改.
例如,要禁用代理,请尝试
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
Run Code Online (Sandbox Code Playgroud)
Gab*_*les 12
这是一种使用简单的.vbs脚本作为"窗口小部件"类型桌面快捷方式的方法.第一次要运行脚本时,单击您创建的.vbs文件.这将使用适当的图标自动为您生成桌面快捷方式.每次单击此后的快捷方式,它切换代理设置,打开一个定时弹出框1秒,告诉您代理是现在是ON还是OFF,并将快捷方式图标更改为ON或OFF符号以指示新代理州.
文件:"C:\ Users\YOUR_USERNAME\Proxy Settings\toggle_proxy_on_off.vbs"
'Toggle your Proxy on and off
'Gabriel Staples - www.ElectricRCAircraftGuy.com
'Written: 21 June 2017
'Updated: 25 June 2017
'References:
' 1) https://stackoverflow.com/a/27092872/4561887
' 2) https://stackoverflow.com/a/26708451/4561887
' Timed message boxes:
' - *****https://technet.microsoft.com/en-us/library/ee156593.aspx
' - https://stackoverflow.com/questions/14105157/automatically-close-msgbox-in-vbscript
' Debug output:
' - ex: Wscript.Echo "here is your message"
Option Explicit
'Variables & Constants:
Dim ProxySettings_path, VbsScript_filename
ProxySettings_path = "C:\Users\Gabriel\Proxy Settings"
VbsScript_filename = "toggle_proxy_on_off.vbs"
Const MESSAGE_BOX_TIMEOUT = 1 'sec; change this value to set how long the message box displays when you toggle the proxy setting
Const PROXY_OFF = 0
Dim WSHShell, proxyEnableVal, username
Set WSHShell = WScript.CreateObject("WScript.Shell")
'get the username string for use in path names, since trying to use the "%USERNAME%" variable directly in path names throws an error
username = WSHShell.ExpandEnvironmentStrings("%USERNAME%")
'Determine current proxy setting and toggle to opposite setting
proxyEnableVal = wshshell.regread("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable")
If proxyEnableVal = PROXY_OFF Then
TurnProxyOn
Else
TurnProxyOff
End If
'Subroutine to Toggle Proxy Setting to ON
Sub TurnProxyOn
'turn proxy on via a registry entry
WSHShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD"
'create/update desktop shortcut
CreateOrUpdateDesktopShortcut("on")
'notify user via an auto-timed popup box
WSHShell.Popup "Internet proxy is now ON", MESSAGE_BOX_TIMEOUT, "Proxy Settings"
End Sub
'Subroutine to Toggle Proxy Setting to OFF
Sub TurnProxyOff
'turn proxy off via a registry entry
WSHShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD"
'create/update desktop shortcut
CreateOrUpdateDesktopShortcut("off")
'notify user via an auto-timed popup box
WSHShell.Popup "Internet proxy is now OFF", MESSAGE_BOX_TIMEOUT, "Proxy Settings"
End Sub
'Subroutine to create or update a shortcut on the desktop
Sub CreateOrUpdateDesktopShortcut(onOrOff)
'create a shortcut
Dim shortcut, iconStr
Set shortcut = WSHShell.CreateShortcut("C:\Users\" + username + "\Desktop\Proxy On-Off.lnk")
'Set the target path (target file) to run when the shortcut is clicked
shortcut.TargetPath = ProxySettings_path + "\" + VbsScript_filename
'Set the working directory. This is necessary in case you ever make this shortcut call a batch (.bat) file, for instance, which in turn calls a .vbs script. In order to know where the .vbs script file/command is located, the shortcut must be operating in the working directory where the .vbs scripts are located. Otherwise, calls to the .vbs scripts from a .bat file this shortcut points to, for instance, won't work since their directories are not in the Windows %PATH% variable, and you'll get an error which states: "'name_of_vbs_script_file' is not recognized as an internal or external command, operable program or batch file."
shortcut.WorkingDirectory = ProxySettings_path
'Set the icon to associate with this shortcut
If onOrOff = "on" Then
iconStr = "on.ico"
ElseIf onOrOff = "off" Then
iconStr = "off.ico"
End If
shortcut.IconLocation = ProxySettings_path + "\Icons\" + iconStr
'Save the shortcut
shortcut.Save
End Sub
Run Code Online (Sandbox Code Playgroud)
从这一点开始,只需直接单击"代理开关"桌面快捷方式即可打开和关闭代理.
这是代理关闭时的样子:
以下是代理开启时的样子:
这是每当您单击快捷方式图标以打开/关闭代理时出现的1秒弹出窗口的示例.
有人可以帮我弄清楚如何通过每次更改图标名称来进一步提高这一点吗? - 即:而不是在快捷方式上说"代理开关",让它说"代理开启"或根据其当前状态"代理关闭".我不确定如何更进一步,我现在已经有足够的时间了...
BOB*_*BOB 10
打开代理上,并关闭具有.VBS
此.vbs MS脚本如果要打开和关闭代理,确定当前代理设置并切换到反对设置非常方便
Option Explicit
Dim WSHShell, strSetting
Set WSHShell = WScript.CreateObject("WScript.Shell")
'Determine current proxy setting and toggle to oppisite setting
strSetting = wshshell.regread("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable")
If strSetting = 1 Then
NoProxy
Else Proxy
End If
'Subroutine to Toggle Proxy Setting to ON
Sub Proxy
WSHShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD"
End Sub
'Subroutine to Toggle Proxy Setting to OFF
Sub NoProxy
WSHShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD"
End Sub
Run Code Online (Sandbox Code Playgroud)
小智 7
Internet Explorer和Google Chrome共享相同的代理设置.因此,如果我们更改Internet Explorer中的设置,那么它也会影响Google Chrome.我们可以从CMD(命令行提示符)更改代理设置.
禁用代理设置:
@ECHO OFF
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
Run Code Online (Sandbox Code Playgroud)
启用代理设置:
@ECHO OFF
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d address:portNumber /f
Run Code Online (Sandbox Code Playgroud)
address:新代理地址
portNumber:端口号
将命令保存在批处理文件中并执行它.它将禁用/启用浏览器的代理设置.
我在以下网址找到了这个答案:http://langbasics.blogspot.in/2012/11/disable-or-enable-proxy-for-internet.html
| 归档时间: |
|
| 查看次数: |
67901 次 |
| 最近记录: |