How do I capture the output of a script if it is being ran by the task scheduler?
Solution 1:
Try this as the command string in Task Scheduler:
cmd /c yourscript.cmd > logall.txt
Solution 2:
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
Solution 3:
With stderr (where most of the errors go to):
cmd /c yourscript.cmd > logall.txt 2>&1
Solution 4:
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