windows 打开 .bat 文件脚本后如何保持 cmd 运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15012344/
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
How to keep cmd running after opening a .bat file script
提问by iDon'tKnow
Basically I have written a "script" in notepad and saved it as a .bat
file. All it does is to change directory. Written like this:
基本上我在记事本中编写了一个“脚本”并将其保存为.bat
文件。它所做的只是更改目录。写成这样:
cd C:\Users\Hello\Documents\Stuff
It does change the directory, but i want to write more after that, within the cmd
. Ex. choose a program to run. It seems simple, but i can't figure it out. I read about pause
, but it just waits for a key and then closes down.
它确实改变了目录,但我想在那之后写更多,在cmd
. 前任。选择要运行的程序。看起来很简单,但我想不通。我读过pause
,但它只是等待一个键然后关闭。
回答by Endoro
Put cmd /k
on the very last line of the script.
放在cmd /k
脚本的最后一行。
回答by Radreaps
Try the following:
请尝试以下操作:
@echo off
Cmd /k
cmd /k
starts a new cmd
instance, /k
stops terminating the console window after the commands are finished.
cmd /k
启动一个新cmd
实例,/k
在命令完成后停止终止控制台窗口。
回答by bizzehdee
end your bat file with @pause
on its own line
用@pause
它自己的行结束你的 bat 文件