设置代理身份验证即使用Vbscript

时间:2014-03-28 17:54:55

标签: vbscript vb6

我想自动填写用户名和密码的代理验证值,即使用vbscript。

将代理IP和端口添加到工具>互联网选项>连接标签>局域网设置后。我被提示使用以下对话框

windows security dialog

是否有使用VBS或VB自动填充此内容?

所以,我有这样的代码

'begin script
Option Explicit
Dim valUserIn
Dim objShell, RegLocate
Set objShell = WScript.CreateObject("WScript.Shell")
RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"
objShell.RegWrite RegLocate,"0","REG_DWORD"
WScript.Sleep(1000)
valUserIn = Inputbox("Enter the Proxy server you want to use.","Proxy Server Required","proxygate.mydomain.com:8080")
if valUserIn = "" then
    RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"
    objShell.RegWrite RegLocate,"0","REG_DWORD"
    'MsgBox "No proxy mode"
else
    RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"
    objShell.RegWrite RegLocate,valUserIn,"REG_SZ"
    RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"
    objShell.RegWrite RegLocate,"1","REG_DWORD"
    'MsgBox "Proxy mode: " & valUserIn
end if
WScript.Quit
'end script

但这只设置了代理ip和端口。

提前致谢..

1 个答案:

答案 0 :(得分:0)

您可以使用Sendkeys shell命令,该命令将在分配了正确的屏幕后为您键入并激活键盘命令。但是,假设您在脚本打开时运行该脚本。如果您正在寻找预先填充该数据的内容。我担心我无法协助这个领域。

Dim WshShell, Success
Set WshShell = WScript.CreateObject("WScript.Shell")
'Wait for window to popup.... 
'if this doesn't activate it directly, try clicking on the window. 
Do Until Success = True
    Success = objShell.AppActivate("Windows Security")
    Wscript.Sleep 1000
Loop
WScript.Sleep 500 
WshShell.SendKeys "Username"
wscript.sleep 500 'allow program to have time to type it in. 
WshShell.SendKeys "{TAB}" 'tab for password field
WshShell.SendKeys "Password"
wscript.sleep 500 'allow program to have time to type it in. 
WshShell.SendKeys "%o" 'Alt + O for hitting "OK" 
wscript.sleep 500