Windows 批量启动命令和 ECHO 完成并关闭 cmd window

Windows batch start command and ECHO on completion and close the cmd's window

我正在尝试在 windows 上为 运行 安排一个脚本。触发部分工作正常。我脚本的重要部分如下所示:

start C:\staging-script -arg1 arg -arg2 arg & ECHO "Did staging"
start C:\prod-script -arg1 arg -arg2 arg & ECHO "Did prod"

当我从cmd.exe运行它时,又打开了两个cmdwindows,都执行脚本,然后windows不关闭。当我尝试为此使用 Windows 调度程序时,它失败了,因为 "resource is still in use"

此外,ECHO 发生在原始 window 中(它们应该发生的地方)但立即发生,而不是在开始任务完成时发生。

start 创建独立进程。进程启动后,将生成消息并执行下一行。

如果您希望两个 started 进程并行执行,而您只是为这些进程“windows”未关闭而烦恼,请插入

exit

在脚本中 started

如果要连续执行进程,即在生成消息并启动进程 2 之前完成进程 1,然后 CALL 批次,不要 start 它们。

尝试将 exit 添加到 windows 执行的每个脚本的末尾。