2017-10-12 19 views
0

다음과 같은 HTA 파일에 VBS 스크립트가 있습니다. 하지만, 어떤 이유로 든 drive() 함수를 실행하면 driveOpen()driveWrite() 전에 실행됩니다. 이 문제를 어떻게 해결할 수 있습니까?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 
+0

'드라이브를()'당신의 코드 AFAICS에 호출되지 않습니다. –

+0

이것은 내 전체 코드가 아니라 VBS 스크립트입니다. 이 스크립트 외부에서 "drive()"함수를 실행합니다. – CALKing

+1

Weird ....'driveWrite()'함수에 리턴 코드를 추가하고 그 리턴 코드에 따라'driveOpen' 함수를 호출하십시오. – ManishChristian

답변

0

대신 두 함수를 차례로 호출하는 driveWrite() 내에서 driveOpen()를 호출하려고합니다.

그래서 drive()과 같을 것이다 :

Function drive() 
    driveWrite() 
End Function 

그리고 driveWrite()이 같을 것이다 :

Function driveWrite() 
    document.getElementById("appstatus").innerHTML = "<h2 style='margin-bottom: 0px;'>Launching Google Drive...</h2>" 
    driveOpen() 
End Function