Introduction - WScript.Sleep
Suspend the execution of the current script for the specified number of milliseconds.
Time is the delay in milliseconds.
WScript.Echo (“10 Seconds have passed”)
A script can force itself to pause by calling the WScript Sleep method. The Sleep method accepts a single parameter that indicates how long, in milliseconds, to pause the script. (There are 1,000 milliseconds in a second and 60,000 milliseconds in a minute.)
You will need to use the Sleep method in your scripts when:
· Your script must wait for an event to occur before continuing to run.
· You want your script to periodically check the status of a system parameter (for example, checking processor usage every 10 seconds).
· Your script is interacting with a user and you want to slow the interaction to a usable speed. For example, when displaying events retrieved from an event log, you might want to insert a pause, giving the user time to read the first event before displaying the next event.
VBScript for creating countdown time is easy with the WScript.Sleep method. These sleep reads in one variable integer time in milliseconds.Wscript.sleep will suspend your script for the indicated number of milliseconds.
Suspension is useful when you need to add a delay or a pause to your project. For example, a delay is often necessary when sending keystrokes via VBScript .Another neat use for the WScript.Sleep function is to create a timer or reminder.
Why required Desktop Exercise reminder?
Remember the days when “work” meant manual labor with a side of blood, sweat, and tears? Neither do we. These days it seems we’re more likely to log hour after idle hour with our bums glued to our seats. And while you may be an Excel champ by day and gym rat by night, recent research suggests that the recommended 30 minutes of cardio five times per week may not undo the health risks of a sedentary lifestyle.
So what’s a worker chained to his or her desk to do? Luckily short bouts of aerobics, strength exercises, and stretching in between conference calls and Gchats can help improve fitness levels and heart health . While these deskercises, or desk exercises for the cubicle-bound, won’t promise Olympic mile times or six-pack abs, they might just improve strength and burn a few extra calories to boot. Our day to day office life we may forgot to do some task for that we required remainder which can make us alert to doing a particular task in particular time for these I designed windows based script to execute.
This script act us reminder every 30 minutes to do action like The Twinkle Top, Stretch your legs
Desktop Exercise reminder script
dtext=InputBox("Do you want me to remind you anything later on?","Reminder")
dTimer=InputBox("Enter timer interval in minutes","Set Timer") 'minutes
do until IsNumeric(dTimer)=True
dTimer=InputBox("Invalid Entry" & vbnewline & vbnewline & _
"Enter timer interval in minutes","Set Timer") 'minutes
if dTimer<>"" then
WScript.Sleep dTimer*60*1000 'convert from minutes to milliseconds
t=MsgBox(dtext & vbnewline & vbnewline & "Restart Timer?", _
vbYesNo, "It's been " & dTimer &" minute(s)")
if t=6 then 'if yes
else 'exit loop
How to Create the WScript file:
1. Create new file Timer (filename).vbs
2. Open Timer.vbs (if necessary, right click and open with notepad)
3. Paste above code in the file
4. Save the file
There is number of way to execute a VBScript. I show below few options how to run the script
1. Double click the file
2. Open Command Prompt Cmd.exe
a. Navigate file location Timer (filename).vbs
b. Type wscript Timer.vbs
c. Type cscript Timer.vbs
d. Type run Timer.vbs
When executed this script prompts the user to set remainder message to remind and set timer using the Input box function. Each time the timer expires, a message box gives you the option to restart timer. I used this script to remind me to do twinkle top every 30 minutes at the office. If you’re an office worker, this example is sure to help you battle the sedentary lifestyle.
Application proposal - WScript.Sleep
1. Timer scheme
1. Exercise Timer (The slog then log, The Mover and Shaker, The Seated Leg raise etc.)
2. Tea Timer
3. Lunch Break Reminder
2. Other scheme
1. Pause Code while External Application Loads
2. Wait for a Connection to become Established
3. Add a delay before using SendKeys
1. Delay sending Login information
2. Pause FTP commands
4. Add a delay to a print job
5. Delay to send the email
6. Shut down/logoff/hibernate the personal computer with in specified time
7. Monitor the remote server popup alert message to admin if process exceeds utilization.