简体   繁体   English

使用 windows 任务计划将批处理文件执行到新命令 window

[英]executing a batch file into a new command window using windows task schedular

I have test_run.bat file to be scheduled to run at specified time and date.我有 test_run.bat 文件计划在指定的时间和日期运行。 I have added this into a task scheduler using following comand:我已经使用以下命令将其添加到任务调度程序中:

set testfile=%%~dp0%test_run.bat release
schtasks /create /tn "test_run" /tr "%testfile%" /sc weekly /d * /mo 1 /st %tt% /sd %dd%

here I'm planning to run "test_run.bat" with "release" as an argument to it.在这里,我计划以“release”作为参数运行“test_run.bat”。 When this task starts, it runs in the background.当此任务启动时,它会在后台运行。 I want this to open a new command window (starting into a folder where this batch file exists) and run this batch file.我希望它打开一个新命令 window(从这个批处理文件所在的文件夹开始)并运行这个批处理文件。

How can I achieve this?我怎样才能做到这一点? Are above mentioned two lines correct(considering release as an argument)?上面提到的两行是否正确(考虑发布作为参数)?

Using start:使用开始:

set testfile=start /c %%~dp0%test_run.bat release
schtasks /create /tn "test_run" /tr "%testfile%" /sc weekly /d * /mo 1 /st %tt% /sd %dd%

I this correct?我这个正确吗?

The start command creates a new command window. start命令创建一个新命令 window。

At its very simplest, the command最简单的命令

start test.bat

will create a new command window and run the batch file in it.将创建一个新命令 window 并在其中运行批处理文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM