I'd like to be able to sleep in a JScript executed by C# MSScriptControl.ScriptControlClass. I thought that maybe the WScript.Sleep() function might be available, but I'm getting a "WScript is undefined" error message when trying that. I'm new to scripting outside of a web browser. I thought that MSScriptControl.ScriptControlClass and Windows Script Host might be related, but maybe they're not. If there isn't a sleep function that is available to the script, then what's the next best thing?
Asked
Active
Viewed 538 times
2 Answers
0
The below javascript works fine for me to sleep within an MsScriptControl routine:
function sleepFor( sleepDuration ){
var now = new Date().getTime();
while(new Date().getTime() < now + sleepDuration){ /* do nothing */ }
}
sleepFor(10000); //10 seconds

Bill Tarbell
- 4,933
- 2
- 32
- 52
0
There is no sleep
function within javascript, maybe you can write a COM executable with implemented sleep
-function or find one, which already has this function.

Aykut Çevik
- 2,060
- 3
- 20
- 27