Specifying the running directory for Scheduled Tasks using schtasks.exe

后端 未结 7 1225
野的像风
野的像风 2020-12-01 07:27

I have an application which gets called by a scheduled task. It moved from Windows Server 2003 to Windows Server 2008. On 2003, the app ran in the directory where the execut

7条回答
  •  佛祖请我去吃肉
    2020-12-01 08:05

    Please see my answer to a similar question, of how to set the "Wake the computer to run this task..." option that is only available from the Task Scheduler UI (and via the XML), and not the schtasks.exe /create command line .

    The nuts and bolts of it are:

    1. Create your task via schtasks.exe /create /tn MyTask ...
    2. Export your task to XML via schtasks.exe /query /xml /tn MyTask > MyTask.xml
    3. Update this XML via XSLT or a search/replace
    4. Re-import (overwriting the old task) via schtasks.exe /create /tn MyTask /xml MyTask.xml /f

    Details are here.

提交回复
热议问题