A new Flexera Community experience is coming on November 25th, click here for more information.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Wscript.Sleep with a VBscript CA doesn't work

CChong
By Level 11 Flexeran
Level 11 Flexeran
I’ve used AdminStudio v5.5 to create a MSI file that contains a VBscript Binary Custom. I have since discovered the Wscript.Sleep command within my VBscript Binary Custom Action causes the script to exit at the sleep line with a ‘Script Error –2146827788’ message. The only way I’ve managed to work around this problem is to substitute the Sleep with a ‘For’ loop, but this is not satisfactory, as the loop time can very depending on the PC spec.

Does anyone know how to make ‘Wscript.Sleep’ work within a Binary VBscript Custom Action ?
(2) Replies
If you have not looked up among the forums, here is one of discussions.
CChong
By Level 11 Flexeran
Level 11 Flexeran
Ah, the “old can’t use Wscript within a Custom Action trick, gets you every time !!”

The workaround you pointed to above is not satisfactory of my situation. There I created my own very simple ‘Sleep’ procedure (below) to use instead of ‘wscript.Sleep’. In addition, I had to change my ‘wscript.quit’ to ‘Sub End’

Sleep(5)

Sub Sleep(ByVal iSleepPeriod)
' Note: Timer returns the number of seconds that have elapsed since midnight.

Dim iStartTime, iEndTime, iCurrentTime
On Error Resume Next

iStartTime = Timer
iEndTime = iStartTime + iSleepPeriod

Do While Timer <= iEndTime
Loop
End Sub