PDA

View Full Version : sleep in VBScript


mishka
05-16-2004, 11:02 AM
Hello
Maybe its trivial but I fail to insert a sleep into a VBScript..

I've tried following pieces of code in "Run Script" action:

Sleep("200")
Sleep(200)
Sleep 200

Set shell = CreateObject("WScript.Shell")
Sleep("200")

Set shell = CreateObject("WScript.Shell")
Sleep(200)

Set shell = CreateObject("WScript.Shell")
Sleep 200

Please help..

kinook
05-17-2004, 08:15 AM
Sleep is provided by the Windows Script Host (WSH) and is not available in VBP (which is a script host itself and does not use WSH). To get a one second delay, you could use:

Wait 1

Function Wait(sec)
start = Timer
Do While Timer-start < sec
' no-op
Loop
End Function

mishka
05-17-2004, 08:47 AM
not good
CPU jumps to 99% when I'm doing this "sleep"

actually I'm trying to build a step that will perform automatic signing of executables with signcode.exe. I'm starting it with WScript's Run method and enter password with SendKeys method.

If I'm using your sleep I never see the dialog, it does not receives enough CPU to run.. :(

kinook
05-17-2004, 09:07 AM
You could write your script code to a .vbs file and call it from a Run Program action, running it under WSH so that Sleep will be available:

cscript "drive:\path\to\file.vbs"

mishka
05-17-2004, 09:14 AM
yes, that's what I did actually.
Just wanted to check if this can be done inside VisualPro project..
Thanks.