******************************************************************************* '脚本说明:使用本脚本可以设置代理为localhost:8080,关闭浏览器后自动取消代理设置。 '创 建 人:wyingquan at hotmail dot com '创建时间:2004-11-24 星期三 '******************************************************************************* |
保存当前设置 Set reg=WScript.CreateObject("WScript.Shell") 设置浏览器使用代理,服务器名localhost,端口号8080 reg.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",1,"REG_DWORD" reg.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer","localhost:8080","REG_SZ" reg.regwrite "HKLM\SYSTEM\ControlSet001\Hardware Profiles\Current\Software\Microsoft\windows\CurrentVersion\Internet Settings",1,"REG_DWORD" reg.regwrite "HKLM\SYSTEM\ControlSet001\Hardware Profiles\0001\Software\Microsoft\windows\CurrentVersion\Internet Settings",1,"REG_DWORD" reg.regwrite "HKLM\SYSTEM\CurrentControlSet\Hardware Profiles\0001\Software\Microsoft\windows\CurrentVersion\Internet Settings\ProxyEnable",1,"REG_DWORD" reg.regwrite "HKLM\SYSTEM\CurrentControlSet\Hardware Profiles\Current\Software\Microsoft\windows\CurrentVersion\Internet Settings\ProxyEnable",1,"REG_DWORD" 获取浏览器执行文件的位置 RunMe=reg.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE\") 等待用户输入要打开的页面 sUrl=InputBox("请输入要打开的URL地址或者取消直接在浏览器地址栏中打开:","VBS For Jmeter","http://") 打开测试页面 Set oExec=Reg.Exec(RunMe & " " & sUrl) 一直等待关闭浏览器为止才继续运行脚本 Do While oExec.Status = 0 WScript.Sleep 100 Loop 撤销代理服务设置 reg.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",ProxyEnable,"REG_DWORD" reg.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer",ProxyServer,"REG_SZ" reg.regwrite "HKLM\SYSTEM\ControlSet001\Hardware Profiles\Current\Software\Microsoft\windows\CurrentVersion\Internet Settings",0,"REG_DWORD" reg.regwrite "HKLM\SYSTEM\ControlSet001\Hardware Profiles\0001\Software\Microsoft\windows\CurrentVersion\Internet Settings",0,"REG_DWORD" reg.regwrite "HKLM\SYSTEM\CurrentControlSet\Hardware Profiles\0001\Software\Microsoft\windows\CurrentVersion\Internet Settings\ProxyEnable",0,"REG_DWORD" reg.regwrite "HKLM\SYSTEM\CurrentControlSet\Hardware Profiles\Current\Software\Microsoft\windows\CurrentVersion\Internet Settings\ProxyEnable",0,"REG_DWORD" Set reg=nothing MsgBox "OK",,"VBS For Jmeter" |