2014-03-28 42 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