简体   繁体   English

执行选择后,命令提示符窗口关闭

[英]Command Prompt Window closes after executing selection

I have successfully made a batch to pretty much do everything I want now how do I get the Command prompt window to remain open after execution for further input? 我已经成功完成了一个批处理,几乎可以做我现在想要的所有事情,如何使命令提示符窗口在执行后保持打开状态以供进一步输入?

 pushd %~dp0 @ECHO OFF cls title XNB NODE :home echo. echo What would you like to do? echo ============= echo. echo 1) Extract all XNB files and output to YAML folder echo 2) Pack all YAML files and output to XNB folder echo 3) Exit echo. set /p web=Type option: if "%web%"=="1" xnb_node.cmd extract Xnb Yaml if "%web%"=="2" xnb_node.cmd pack Yaml Xnb if "%web%"=="3" exit goto home 

Change this: 更改此:

if "%web%"=="1" xnb_node.cmd extract Xnb Yaml
if "%web%"=="2" xnb_node.cmd pack Yaml Xnb
if "%web%"=="3" exit

to

if "%web%"=="1" xnb_node.cmd extract Xnb Yaml && cmd /k && exit
if "%web%"=="2" xnb_node.cmd pack Yaml Xnb cmd /k && exit
if "%web%"=="3"  cmd /k && exit

It is not very good to use it this way, you may encounter some issues with title of the command prompt window and some other stuff, so I recommend using CALL command as Adam Morgan said. 这样使用它不是很好,您可能会遇到命令提示符窗口的标题等一些问题,因此我建议使用Adam Morgan所说的CALL命令。

You must use the call command when you execute other batch files if you don't want the interpreter to abort the parent batch program. 如果您不希望解释器中止父批处理程序,则在执行其他批处理文件时必须使用call命令

From TechNet : TechNet

Calls one batch program from another without stopping the parent batch program. 在不停止父批处理程序的情况下从另一个调用一个批处理程序。 The call command accepts labels as the target of the call. call命令接受标签作为呼叫目标。 Call has no effect at the command-line when used outside of a script or batch file. 在脚本或批处理文件之外使用时,调用在命令行无效。

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

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