'Make vbs wait until a time and then run a batch script
I want to make a vbscript that waits until its 11:00AM and when it turns that time i want it to launch a batch script. I only know how to use
WScript.Sleep
But i want to make it run at a certain time.
Solution 1:[1]
Check system time with Now()
:
Dim time, WshShell
Set WshShell = CreateObject("WScript.Shell")
time = Now()
hm = Minute(time) + 100 * Hour(time)
' Only execute between 11:00AM and 11:30AM
While hm < 1100 Or hm > 1130
WScript.Sleep 2
time = Now()
hm = Minute(time) + 100 * Hour(time)
Wend
' Do your job here
WshShell.Run "some.bat", , False
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Community |