vbs如何实现定时运行程序?

来源:百度知道 编辑:UC知道 时间:2024/06/15 12:25:08

比如说你想在5秒后打开任务管理器
Dim objws
Set objws=WScript.CreateObject("wscript.shell")
wscript.sleep 5000
objws.RUN "taskmgr.exe"

Option Explicit

On Error Resume Next

Dim sProgramme, sRunTime, aTime, iHour, iMinute, oShell

sProgramme = "C:\Test.exe" '------指定程序
sRunTime = "12:00" '------指定运行时间

aTime = Split(sRunTime, ":")
iHour = CInt(aTime(0))
iMinute = CInt(aTime(1))

Do While True
If (Hour(Now) = iHour) And (Minute(Now) = iMinute) Then
Set oShell = CreateObject("WScript.Shell")
oShell.Run sProgramme, 1, False
Set oShell = Nothing
Exit Do
End If
WSH.Sleep 1000
Loop