0
我在一個HTA文件中有一個VBS腳本,看起來像這樣。但是,當我運行drive()
函數時,它由於某種原因在driveWrite()
之前運行driveOpen()
。我該如何解決這個問題?VBS腳本跳過功能
Sub Wait(Time)
Dim wmiQuery, objWMIService, objPing, objStatus
wmiQuery = "Select * From Win32_PingStatus Where Address = '1.1.1.1' AND Timeout = " & Time
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objPing = objWMIService.ExecQuery(wmiQuery)
For Each objStatus In objPing
Next
End Sub
Function drive()
driveWrite()
driveOpen()
End Function
Function driveWrite()
document.getElementById("appstatus").innerHTML = "<h2 style='margin-bottom: 0px;'>Launching Google Drive...</h2>"
End Function
Function driveOpen()
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = False
IE.Menubar = 0
IE.Toolbar = 0
IE.Statusbar = 0
IE.Left = -7
IE.Top = 0
IE.Height = screen.AvailHeight + 7
IE.Width = screen.AvailWidth + 14
IE.Navigate "https://login.tyreso.se/wa/auth?authmech=Personal-%20och%20elevinloggning&location=https%3a%2f%2flogin.tyreso.se%2fwa%2fauth%2fsaml%2f%3fSAMLRequest%3dfVLLTgIxFN2b%252BA%252BT7ueFJpKGGYMaIgnqBEYX7krnMhT7srcD%252BveWQYIudHt67nnc3tH1h5LRFhwKowuSJxmJQHPTCN0W5LmexENyXZ6fjZApaem482s9h%252FcO0EdhUiPtHwrSOU0NQ4FUMwVIPaeL8cOMDpKMWme84UaSaHpXEL1pN1ZYZXTbrpkU2hq2ae1bw4CvltJqqdTybQ0kejnGGuxjTRE7mGr0TPsAZflVnA3jQVYPLujlkObZK4mqb6cboQ8N%252Fou1PJCQ3td1FVdPi7oX2IoG3GNgF6Q1ppWQcKP29hVDFNsAr5jEEG%252BMCM6HgLdGY6fALcBtBYfn%252Bawga%252B8t0jTd7XbJSSZlaeeXif90gCZBSBlHUvbLpX0%252F92Or%252F6dnR3dSnvRH6Q%252Bp8vvT9l2md5WRgn9GYynN7tYB86GId13oMTFOMf%252B3W57kPSKaeNVTaafRAhcrAQ2J0vLg%252Bvs6ws18AQ%253D%253D%26RelayState%3dhttps%253A%252F%252Faccounts.google.com%252FCheckCookie%253Fcontinue%253Dhttps%25253A%25252F%25252Fdrive.google.com%25252Fdrive%25252F%2526service%253Dwise%2526hl%253Den%2526checkedDomains%253Dyoutube%2526checkConnection%253Dyoutube%25253A607%25253A1%2526pstMsg%253D1"
Do Until IE.ReadyState = 4
Wait(200)
Loop
IE.Document.All.Item("username").Value = user
IE.Document.All.Item("password").Value = pass
IE.Document.All.Item("Submit1").Click
Wait(2000)
Do Until IE.ReadyState = 4
Wait(200)
Loop
url = IE.LocationURL
If url="https://login.tyreso.se/wa/auth" Then
X=MsgBox("An error occured. Please stand by and try again.",0+16,"Login")
document.getElementById("appstatus").innerHTML = "<h2 style='margin-bottom: 0px;'>An error occured</h2>"
Else
IE.Visible = True
document.getElementById("appstatus").innerHTML = "<h2 style='margin-bottom: 0px;'>Google Drive has opened sucessfully</h2>"
End If
End Function
'驅動器()'永遠不會在你的代碼AFAICS調用。 –
這不是我的整個代碼,只是VBS腳本。我在這個腳本之外運行「drive()」函數。 – CALKing
奇怪....將函數'driveWrite()'的返回碼添加到函數'driveOpen'中,並根據該返回碼進行調用。 – ManishChristian