How do I capture the output of a script if it is being ran by the task scheduler?
To supplement @user2744787's answer, here is a screenshot to show how to use cmd
with arguments in a Scheduled Task:
Program/script: cmd
Add arguments: /c run_with_default_port.bat > IMQuantWebServices.log
The >>
will append the log file, rather than overwriting it each time. The 2>&1
will also send errors to your log file.
cmd /c YourProgram.exe >> log.txt 2>&1
With stderr (where most of the errors go to):
cmd /c yourscript.cmd > logall.txt 2>&1
Try this as the command string in Task Scheduler:
cmd /c yourscript.cmd > logall.txt