windows 为什么批处理文件执行后 CMD 窗口不会关闭?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18738490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why won't the CMD window close after Batch file execution?
提问by 123r789
I am trying to execute a file by placing the appropriate command into a batch file. After completing the file execution the command window is not closing automatically. I tried it with the Exit command too but it is not closing the window automatically.
我试图通过将适当的命令放入批处理文件来执行文件。完成文件执行后,命令窗口不会自动关闭。我也用 Exit 命令尝试过,但它没有自动关闭窗口。
The command in my batch file:
我的批处理文件中的命令:
start "" /w /B /d "%CD%\Project-Aug-New\MyCardApi\trunk\src\build\bin" MyCardApiTest_32d.exe
exit 0
回答by Jon
The /w
parameter makes START
wait until the process it launches has exited. Remove it:
该/w
参数START
等待它启动的进程退出。去掉它:
start "" /B /d ...
This will let your batch file continue running and exit immediately.
这将使您的批处理文件继续运行并立即退出。
回答by foxidrive
Remove the /b
(and the /w
) from the start command. The /b
starts the program in the same window and the /w
keeps the window open until the program terminates.
从 start 命令中删除/b
(和/w
)。将/b
在同一窗口中启动程序和/w
保持窗口打开,直到程序终止。
回答by RckLN
You can close the console at the end
您可以在最后关闭控制台
For example:
例如:
start /b taskkill /F /IM bank01.exe
..
..
taskkill /F /IM cmd.exe