2014-03-28 43 views
0

我想自动填充用户名和密码的代理身份验证值,即使用vbscript。为使用Vbscript设置代理身份验证

将代理IP和端口添加到工具> Internet选项>连接选项卡> LAN设置后。我提示以下对话框

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和端口。

在此先感谢..

回答

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 
+0

诀窍:)。非常感谢 – user3104255