简体   繁体   English

如何使用批处理文件设置Task Scheduler Start in(可选)属性

[英]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.

相关问题 使用任务计划程序运行包含start / w命令的批处理文件 - Using Task Scheduler to run a batch file that contains the start /w command 如何使用任务计划程序使用批处理文件复制和重命名文件? - How to use batch file to copy and rename file using task scheduler? 如何使用任务计划程序和批处理文件运行SSIS包 - How to Run SSIS Package Using Task Scheduler and Batch File Windows 任务计划程序不启动批处理文件任务 - Windows Task Scheduler doesn't start batch file task Windows Service-在Windows 2012 Server R2上使用任务计划程序使用批处理文件启动服务 - windows service - start service using batch file using task scheduler on windows 2012 server R2 如何在 Windows 8 中启动使用任务计划程序最小化的批处理文件? - %comspec% 方法在 Windows 7 之后不再起作用 - How to start a batch file minimized with task scheduler in Windows 8? - %comspec% method not working anymore after Windows 7 任务计划程序-批处理文件-路径 - task scheduler - batch file - path 具有配置的任务计划程序批处理文件 - Task Scheduler Batch File with Configuration 任务计划程序未运行批处理文件 - Task Scheduler Not Running Batch File 如何使用批处理文件将文件从本地系统复制到ftp服务器-Task Scheduler - How to copy file from local system to ftp server using Batch file- Task Scheduler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM