vbs如何实现定时运行程序?
展开全部
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询