简体   繁体   English

Windows-启动应用程序后使CMD.exe自动关闭

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

相关问题 如何使用 Node JS 执行 Windows Shell 命令 (Cmd.exe) - How To Execute Windows Shell Commands (Cmd.exe) with Node JS 错误系统调用生成 C:\\Windows\\system32\\cmd.exe - error syscall spawn C:\Windows\system32\cmd.exe Angular CLI 安装失败 - 生成 C:\\Windows\\System32\\cmd.exe; 恩诺恩 - Angular CLI installation Failure - spawn C:\Windows\System32\cmd.exe; ENOENT 生成 C:\Windows\system32\cmd.exe;C:\Program Files\Git\bin ENOENT - spawn C:\Windows\system32\cmd.exe;C:\Program Files\Git\bin ENOENT 从Node.js服务器执行cmd.exe - Execute cmd.exe from Nodejs server NodeJs 错误:产生 C:\\Windows\\system32\\cmd.exe; ENOENT - NodeJs Error: spawn C:\Windows\system32\cmd.exe; ENOENT 如何从节点bash上运行的javascript代码运行Windows cmd.exe命令? - How to run windows cmd.exe commands from javascript code run on node bash? 准备写我的第一个 C 程序,得到 Error: spawn C:\WINDOWS\system32\cmd.exe ENOENT - Getting ready to write my first C program, getting Error: spawn C:\WINDOWS\system32\cmd.exe ENOENT Liferay 7.1 主题创建:命令失败:C:\Windows\system32\cmd.exe /s /c "yo "--version"" - Liferay 7.1 theme creation: Command failed: C:\Windows\system32\cmd.exe /s /c "yo "--version"" node.js和命令行(cmd.exe) - node.js and command line (cmd.exe)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM