[英]How to set task scheduler Start in(Optional) property using Batch file
I have created a batch file using the cmd: 我已经使用cmd创建了一个批处理文件:
SchTasks /Create /SC DAILY /TN "Task" /TR "%~dp0\Data.bat" /ST 09:00
How to set "Start In" property using cmd ? 如何使用cmd设置“开始于”属性?
SchTasks does not have an option to specify the "Start In" path. SchTasks没有选项来指定“开始于”路径。
But you can modify your "Data.bat" and insert a CD or PUSHD command at the top to establish the correct working folder. 但是您可以修改“ Data.bat”并在顶部插入CD或PUSHD命令以建立正确的工作文件夹。
If you cannot modify "Data.bat", then create a new batch file "callData.bat" with the correct commands: 如果您无法修改“ Data.bat”,则使用正确的命令创建一个新的批处理文件“ callData.bat”:
@echo off
cd /d "c:\your\Start\Path"
"d:\your\script\path\Data.bat"
and then schedule "callData.bat" instead of "Data.bat" 然后安排“ callData.bat”而不是“ Data.bat”
Another option is to schedule cmd.exe and have that set the current folder and execute the batch script. 另一个选择是计划cmd.exe并设置当前文件夹并执行批处理脚本。 (note: the quote rules can be a bit tricky - I'm not sure if I got them correct in this case)
(注意:引用规则可能有点棘手-在这种情况下,我不确定是否正确)
SchTasks /Create /SC DAILY /TN "Task" /TR "cmd.exe /c cd /d \"c:\your\start\path\" & \"%~dp0\Data.bat\"" /ST 09:00
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.