Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\Scheduled Jobs\mybat.bat" & Chr(34), 0
Set WinScriptHost = Nothing
and schedule it. The second argument in this example sets the window style. 0 means "hide the window."
Complete syntax of the Run method:
object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])
Hope this will help you.
1. Create a scheduled task which simply executes a batch file, say
c:\mybatch.bat. You can disable this scheduled task because you don't
really want it to run on a schedule, but rather when you tell it to.
Create a new file which contains the path and filename of the batch
file you really want to execute, and save this new file as
c:\mybatch.bat (such that when the scheduled task is run, it will
execute this new batch file).
3. In your web app code, create a
new process which will simply run the schedule task, as follows:
myprocess.StartInfo = new ProcessStartInfo("cmd.exe", "schtasks /run