Set interval in vbscript

2019-09-08 06:32发布

问题:

I want to set interval time in vbscript Following is my code

Set objWord = CreateObject("Word.Application")
endTime= Timer()
'Set visibilty for the client application
objWord.Visible = True

WScript.Sleep 1000
'Close MS word process
objWord.Quit

I found WScript.Sleep 1000 or WScript.Sleep(1000) 1000 is in millisecond but both of them are not working fine, I am using window7

回答1:

Quick-and-dirty batch command is the safest and surest (though not the most accurate) way to get a delay.

' Get a 10 seconds delay

Delay 10
Sub Delay( seconds )
Dim wshShell
Set wshShell = CreateObject( "WScript.Shell" )
wshShell.Run "ping -n " & ( seconds + 1 ) & " 127.0.0.1", 0, True
Set wshShell = Nothing
End Sub

As seen on Rob van der Woude's Scripting Page .Here you can also find lot of good scripts



标签: vbscript wsh