Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set delay in vbscript

Tags:

vbscript

How to set delay in vbscript?

WScript.Sleep(100) does not work on Windows XP, Vista.

like image 447
Mark Avatar asked Nov 13 '09 12:11

Mark


People also ask

What is WScript echo in VBScript?

You can use WScript. Echo to see exactly what VBScript passes out; if the string you see in the result of WScript. Echo works in a command-prompt window, it will work as the first argument for the Run method.

What is WScript sleep?

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.)


2 Answers

Work this end (XP).

Create a new file, call it test.vbs. Put this in it.

WScript.Sleep 1000 MsgBox "TEST" 

Run it, notice the delay before the message box is shown.

Note, the number is in Milliseconds, so 1000 is 1 second.

like image 84
badbod99 Avatar answered Sep 20 '22 06:09

badbod99


If you're trying to simulate a sleep delay in VBScript but WScript is not available (eg: your script is called from Microsoft's BGInfo tool), then try the following approach.

The example below will delay until 10 seconds from the moment the instruction is processed:

Dim dteWait dteWait = DateAdd("s", 10, Now()) Do Until (Now() > dteWait) Loop 
like image 35
Original Paulie D Avatar answered Sep 22 '22 06:09

Original Paulie D