SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
can't make scripts sleep

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
can't make scripts sleep
Author Message
Andrew Conrad



Joined: 04 Nov 2002
Posts: 5

Post can't make scripts sleep Reply with quote

I am having problems making a vb script sleep. I am
using the WScript.Shell object, but it doesn't seem
to be working. Is that object available or should
I be using something else?

below is the method I wrote and I am calling which
returns successful values, but the actual time
doesn't match the amount of time it should be sleeping.

' causes the system to sleep for a while
public function sleeper( millis )
on error resume next
Dim wshShell
set wshShell = createObject("WScript.shell")

if not isObject(wshShell) then

sleeper = -1
else

wshShell.sleep( millis )

sleeper = millis / 1000
end if
end function

Thu Dec 05, 2002 1:46 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7963

Post Re: can't make scripts sleep Reply with quote

Can you post fragment of your code where you call the sleeper function?
Does it "sleep" at all?

: I am having problems making a vb script sleep. I am
: using the WScript.Shell object, but it doesn't seem
: to be working. Is that object available or should
: I be using something else?

: below is the method I wrote and I am calling which
: returns successful values, but the actual time
: doesn't match the amount of time it should be sleeping.

: ' causes the system to sleep for a while
: public function sleeper( millis )
: on error resume next
: Dim wshShell
: set wshShell = createObject("WScript.shell")

: if not isObject(wshShell) then

: sleeper = -1
: else

: wshShell.sleep( millis )

: sleeper = millis / 1000
: end if
: end function

Thu Dec 05, 2002 2:37 pm View user's profile Send private message
Andrew Conrad



Joined: 04 Nov 2002
Posts: 5

Post Re: can't make scripts sleep Reply with quote

basically I call this 15 times:

log_this "stopService()->Waiting " & sleeper(5000) & " seconds. Service State = " & colItem.State & "; Current Time = " & Now()

log_this logs the string to a log file. Assumming
the sleeper() method is successful, the Now()
statement should increment by roughly 5 seconds
every time, but it doesn't. I have 15 log
statements with the exact same time.

any ideas?

: Can you post fragment of your code where you call the sleeper function?
: Does it "sleep" at all?


Thu Dec 05, 2002 4:39 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7963

Post Re: can't make scripts sleep Reply with quote

comment out 'on error resume next' in your function to find out where the script does not work. Most likely you have an error in the sleeper() function.

: basically I call this 15 times: log_this "stopService()->Waiting
: " & sleeper(5000) & " seconds. Service State = "
: & colItem.State & "; Current Time = " & Now()

: log_this logs the string to a log file. Assumming
: the sleeper() method is successful, the Now()
: statement should increment by roughly 5 seconds
: every time, but it doesn't. I have 15 log
: statements with the exact same time.

: any ideas?

Thu Dec 05, 2002 5:30 pm View user's profile Send private message
Andrew Conrad



Joined: 04 Nov 2002
Posts: 5

Post Re: can't make scripts sleep Reply with quote

You were right. I was calling WshShell.sleeep which
doesn't exist.

What kind of sleep method can I call? How do I
reference WScript which has a method sleep() ?

: comment out 'on error resume next' in your function to find out where the
: script does not work. Most likely you have an error in the sleeper()
: function.

Thu Dec 05, 2002 6:31 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7963

Post Re: can't make scripts sleep Reply with quote

You are trying to use functions not available in the standard version of the
VBScript. Actually you are trying to call private functions of the Windows
Scripting Host object. These functions are used to control run-time of
WScript.exe and they have nothing to do directly with the VBScript
environment.

Please see the online VBScript Manual for complete list of available
methods and functions.

Please keep in mind that VBScript jobs within 24x7 are executed by the built-
in VBScript engine and not by the wscript.exe.
If you need to implement Sleep method in your VBScript job you can use the following code

Sub sleeper()

JALScript.Execute("Wait 2")
End Sub

Another solution is to create an external .VBS file and run it as command line job.

By the way, manipulating services in JAL no more complicated than in VBScript plus you have an extra option to write progress messages to the common job log file.

: You were right. I was calling WshShell.sleeep which
: doesn't exist.

: What kind of sleep method can I call? How do I
: reference WScript which has a method sleep() ?

Thu Dec 05, 2002 6:58 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.