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

Re: Calling an OLE method but continuing a timer within VBS by mr_unreliable

mr_unreliable
Fri Jun 24 16:04:52 CDT 2005

hi Matt,

You might try placing the problematical code into ANOTHER script,
and then running that script via "wshScriptExec".

That will provide you with a "status" (running or finished), which
may be polled periodically. If you find that it is still running
for an overly long period, then that would imply that it was
hung up, allowing you to take corrective action.

Although I am less familiar with it, you may also make use of the
"remote" scripting facility, which will also provide a status.
Note that running a "remote" script does NOT mean that it has to
run on another computer. You can use the "remote" scripting
capabilities to run a script on your own computer.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)





Matt in BrisVegas Australia wrote:
> 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

Re: Calling an OLE method but continuing a timer within VBS by MattinBrisVegasAustralia

MattinBrisVegasAustralia
Wed Jun 29 03:18:02 CDT 2005

Mr Unreliable,

That was a not very unreliable suggestion at all... Worked a treat. Thanks a
lot

Cheers,
Matt



"mr_unreliable" wrote:

> hi Matt,
>
> You might try placing the problematical code into ANOTHER script,
> and then running that script via "wshScriptExec".
>
> That will provide you with a "status" (running or finished), which
> may be polled periodically. If you find that it is still running
> for an overly long period, then that would imply that it was
> hung up, allowing you to take corrective action.
>
> Although I am less familiar with it, you may also make use of the
> "remote" scripting facility, which will also provide a status.
> Note that running a "remote" script does NOT mean that it has to
> run on another computer. You can use the "remote" scripting
> capabilities to run a script on your own computer.
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>
>
>
>
>
> Matt in BrisVegas Australia wrote:
> > 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
>

you're welcome by mr_unreliable

mr_unreliable
Wed Jun 29 17:41:47 CDT 2005

and thanks for the lesson in 'strine(sp?).

I shall have to add "Worked a treat" to my Austrailian distionary,
along with "Shiela", "g'day mate", "baboonaphile", "drongo", "onya",
"rat bag", and all the other words that make Aussie colorful
(coloUrful?) to American ears...

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)


Matt in BrisVegas Australia wrote:
> Worked a treat. Thanks a lot