Hi VBS gurus,
I have a problem which I am trying to get resolved in time for a probation
review for a new job (Good marks = Continue to get paid)...
Basically, I have written a VBS script to do an unattended test of an
application called OPP over a Citrix environment. The script is included at
the end of this post in all its glory. All works well when the
username/password variables function correctly to log in:
success = OPPApplication.Login(loginname, password)
If all works, success is returned as TRUE and away we go. Problem is, when
the username/password don't function, the .Login OLE method just opens a
window on the Citrix server and awaits user entry. Since this is meant to
function unattended, the window just sits there waiting and never returns to
the VBS script to return success = FALSE. You can see I have tried to set a
timer to return success = FALSE if no luck after 10 secs but the problem I
have is that control is never returned back to the VBS script from the
application call, so the timer never continues counting.
If anybody has advice on how I can do this (Somebody I asked mentioned
calling the OLE method asynchronously - I have google'd it unsuccessfully so
far) I'd be eternally grateful... Thanks for reading this far, sorry about
the wordiness
Matt
---- VBS script below ----
OPTION EXPLICIT
Function DateTime (d)
DateTime = Day(d) & "/" & Month(d) & "/" & Year(d) & " " & Hour(d) & ":" &
Minute(d) & ":" & Second(d) & ".00"
End Function
'Declare OPP application object and variables
Dim OPPApplication
Dim success
Dim loginname
Dim password
'Parameters passed from command line
Dim OPPArgs
'Timer to check for time-out of login attempts
Dim OPPTimer
Dim OPPTimer2
'Availability of the application
Dim availability
'Set OPPApplication
Set OPPApplication = CreateObject("opp.application")
Set OPPArgs = WScript.Arguments
'Set variables to command line parameters
loginname = OPPArgs.Item(0)
password = OPPArgs.Item(1)
availability = "0.0"
'Set timer
OPPTimer = Timer()
'Will give the monitor 10 seconds to successfully login to Open Plan
OPPTimer2 = OPPTimer + 10
'Attempt login to Open Plan
While OPPTimer < OPPTimer2
success = OPPApplication.Login(loginname, password) <-- This is my problem
OPPTimer = Timer() <-- Never gets back to here
Wend
'Test if able to login successfully
If success = "True" Then
'OPP has successfully logged in
availability = "1.0"
'Output final results and availability of test
WScript.stdOut.WriteLine DateTime(Now) &
",""General.Availability"",""" & availability & """"
Else
'OPP has failed to login - availability will be "0.0"
WScript.stdOut.WriteLine DateTime(Now) & ",""General.Availability"","""
& availability & """"
End If
WScript.Quit