我正在编写一个VB脚本代码,作为cimplicity对象的一部分。代码基本上需要打开具有特定URL的IE并自动登录到网页。登录是一个" windows security"弹出窗口。我能以务实的方式登录吗?
以下是我的代码的一部分:
On Error GoTo ERR_TRP
Dim IE
Dim UID As CimObjectVariable
Dim PWD As CimObjectVariable
Dim URL As CimObjectVariable
Dim sUID As String
Dim sPWD As String
Dim sURL As String
Set UID = CimGetScriptOwner().GetVariable("USER")
Set PWD = CimGetScriptOwner().GetVariable("PWD")
Set URL = CimGetScriptOwner().GetVariable("IP")
sUID = UID.Value
sPWD = PWD.Value
sURL = URL.Value
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = 1
IE.navigate sURL
Sleep(1000)
Err_Trp:
x = MSGBOX ("Cannot open the camera Please check User-Password-IP", 0 , "Eror")
答案 0 :(得分:1)
正如omegastripes所写,你不能在VBS中声明可变数据类型,但是在导航到页面后将用户名/密码发送到弹出登录窗口使用此代码:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Windows Security"
WshShell.SendKeys "YourUserID"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep(100)
WshShell.SendKeys "YourPassword"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{ENTER}"