Tuesday, 14 September 2010

HTA Sleep Command

This is a hdany piece of code i found to perform a sleep inside a HTA file.
HTA's do not support Wscript calls so basically this makes an external VBS Script
to perform the action

Sub
TestIt
Sleep 5000
MsgBox "ok"
End Sub

Sub Sleep(MSecs)
Set fso = CreateObject("Scripting.FileSystemObject")
If Fso.FileExists("sleeper.vbs")=False Then
Set objOutputFile = fso.CreateTextFile("sleeper.vbs", True)
objOutputFile
.Write "wscript.sleep WScript.Arguments(0)"
objOutputFile
.Close
End If
CreateObject("WScript.Shell").Run "sleeper.vbs " & MSecs,1 , True
End Sub

No comments:

Post a Comment