Internet explorer 在VBS中请求选项
我是VBS脚本新手,需要您的帮助和建议,以帮助我如何使脚本与选项一起工作 我的工作网络使用代理,而我的家庭网络不使用代理,我已经设法让脚本工作,以便在需要时将代理从打开切换到关闭,但这仍然让我怀疑它是启用还是禁用的 我想让VBS脚本问我“Internet explorer 在VBS中请求选项,internet-explorer,vbscript,proxy,windows-10,Internet Explorer,Vbscript,Proxy,Windows 10,我是VBS脚本新手,需要您的帮助和建议,以帮助我如何使脚本与选项一起工作 我的工作网络使用代理,而我的家庭网络不使用代理,我已经设法让脚本工作,以便在需要时将代理从打开切换到关闭,但这仍然让我怀疑它是启用还是禁用的 我想让VBS脚本问我“ 启用代理/2.禁用代理 然后运行与该选项对应的代码部分 我没有任何VBS的经验,我完全不了解这一点,并将感谢任何帮助这一点 Option Explicit Dim WSHShell, strSetting Dim ObjShell Set WSHShell
Option Explicit
Dim WSHShell, strSetting
Dim ObjShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
'Elevate VBS to run as Administrator
If WScript.Arguments.length = 0 Then
Set ObjShell = WScript.CreateObject("Shell.Application")
ObjShell.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" &_
" RunAsAdministrator", , "runas", 1
Wscript.Quit
End if
'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 "Tested & Working"
Sub Proxy
WSHShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD"
wscript.sleep 500
WSHShell.Exec "cmd /C netsh.exe winhttp import proxy source=ie"
End Sub
'Subroutine to Toggle Proxy Setting to OFF "Tested & Working"
Sub NoProxy
WSHShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD"
wscript.sleep 500
WSHShell.Exec "cmd /C netsh.exe winhttp reset proxy"
End Sub
您可以使用是/否/取消:
您可以使用是/否/取消:
answer = MsgBox("Enable Proxy?", vbYesNoCancel + vbQuestion)
Select Case answer
Case vbYes : Proxy
Case vbNo : NoProxy
Case Else : WScript.Echo "Cancelled"
End Select