Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there such thing as a "wait" function? 1

Status
Not open for further replies.

EdRev

Programmer
Aug 29, 2000
510
0
0
US
I have a vbscript that only execute if it finds a file. If it didn't find the file, it will write a message to a text file and loop until it eventually finds it. Is there a wait function that I can incorporate on my code so that it will "wait" a few minutes before it loops again?

Any help will be greatly appreciated.
 
From the Windows Script help:

Sleep Method

Suspends script execution for a specified length of time, then continues execution.

object.Sleep(intTime)

Arguments

object
WScript object.

intTime
Integer value indicating the interval (in milliseconds) you want the script process to be inactive.

Remarks
The thread running the script is suspended, releasing its CPU utilization. Execution resumes as soon as the interval expires. Using the Sleep method can be useful when you are running asynchronous operations, multiple processes, or if your script includes code triggered by an event. To be triggered by an event, a script must be continually active (a script that has finished executing will certainly not detect an event). Events handled by the script will still be executed during a sleep.

Note Passing the Sleep method a 0 or –1 does not cause the script to suspend indefinitely.

Example:
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 100

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top