Run Any File With Vbs At A Specific Time

[Solved] Run Any File With Vbs At A Specific Time | Vb - Code Explorer | yomemimo.com
Question : Run any file with vbs at a specific time

Answered by : hackoo

Option Explicit
Dim TaskName,AppFullPath,StartTime,Frequency
'************* Four params can be changed here********************
TaskName = "Execute Notepad by Hackoo"
AppFullPath = "C:\windows\notepad.exe"
StartTime = "10:00"
Frequency = "Minute"
REM The value of frequency can be taken
Rem as "MINUTE", "HOURLY", "DAILY", "WEEKLY" or "MONTHLY"
REM https://technet.microsoft.com/en-us/library/bb490996.aspx
REM Don't change anything under this line
'************************** Main *********************************
Call CreateTask(TaskName,AppFullPath,StartTime,Frequency)
'*****************************************************************
Sub CreateTask(TaskName,AppFullPath,StartTime,Frequency)
Dim ws,strtask,exitcode
Set ws = CreateObject("Wscript.Shell")
strtask = "schtasks /create /sc "& Frequency &" /tn "& qq(TaskName) & _ " /tr "& qq(AppFullPath) & _ " /st " & StartTime & " /f"
exitcode = ws.Run(strtask, 0, True)
If exitcode <> 0 Then WScript.Echo "External command failed: " & Hex(exitcode)
Else wscript.echo "The Task "& qq(TaskName) & " is created successfully !"& vbcrlf &_ "to be run "& qq(Frequency) &" with a StartTime at " & qq(StartTime) & ""
End If
End Sub
'*****************************************************************
Function qq(str) qq = chr(34) & str & chr(34)
End Function
'*****************************************************************

Source : https://stackoverflow.com/questions/47125910/run-any-file-with-vbs-at-a-specific-time/47196907# | Last Update : Wed, 24 Aug 22

Answers related to run any file with vbs at a specific time

Code Explorer Popular Question For Vb