How do I capture the output of a script if it is being ran by the task scheduler?

前端 未结 9 824
旧巷少年郎
旧巷少年郎 2020-12-02 08:37

Using Windows Server 2008, how do I go about capturing the output of a script that is being ran with the windows task scheduler?

I\'m testing a rather long custom pr

9条回答
  •  萌比男神i
    2020-12-02 09:26

    Example how to run program and write stdout and stderr to file with timestamp:

    cmd /c ""C:\Program Files (x86)\program.exe" -param fooo >> "c:\dir space\Log_%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.txt" 2>&1"
    

    Key part is to double quote whole part behind cmd /c and inside it use double quotes as usual. Also note that date is locale dependent, this example works using US locale.

提交回复
热议问题