[英]Windows - Make CMD.exe To Autoclose After Starting Application
File a.bat
:- 档案
a.bat
:-
start powershell "npm init"
code .
When I double click the above file, it opens a powershell window with the npm init
command executed in it and it also opens visual studio code
with current directory opened in it. 当我双击上面的文件时,它将打开一个Powershell窗口,其中执行了
npm init
命令,它还打开了visual studio code
,并在其中打开了当前目录。 cmd.exe exits after this. 此后cmd.exe退出。 But for the following bat file:-
但是对于以下蝙蝠文件:
start /min powershell "gulp scss; gulp watch-scss;"
start /min powershell "gulp js; gulp watch-js;"
start /min powershell "http-server;"
code .
when I double click it, everything happens as it should except that cmd.exe does not exits and stays open in the waiting state (as it is waiting for visual studio code to close.) 当我双击它时,一切都会发生,但cmd.exe不会退出并在等待状态下保持打开状态(因为它正在等待Visual Studio代码关闭)。
How can I make cmd.exe to exit when all the commands have been executed (like in the case of a.bat
)? 在执行完所有命令后(如
a.bat
),如何使cmd.exe退出?
Update 更新资料
The batch file does not keep cmd.exe opened if I omit the last line code .
如果我省略最后一行
code .
则批处理文件不会使cmd.exe保持打开状态code .
. 。 The following batch file works perfectly fine:-
以下批处理文件可以正常工作:
start /min powershell "gulp scss; gulp watch-scss;"
start /min powershell "gulp js; gulp watch-js;"
start /min powershell "http-server;"
The problem starts when I add the line code .
当我添加行
code .
时,问题就开始了code .
Try doing these 尝试做这些
start "" /min powershell "gulp scss; gulp watch-scss;"
start "" /min powershell "gulp js; gulp watch-js;"
start "" /min powershell "http-server;"
code .
or if youre running a powershell file, use this 或者如果您正在运行Powershell文件,请使用此文件
Powershell.exe -executionpolicy remotesigned -File location\to\ps\file.ps
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.