windows CMD 脚本:如何关闭 CMD

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1522725/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:48:37  来源:igfitidea点击:

CMD Script: How to close the CMD

windowscommand-linescriptingcmd

提问by Abs

I have created a small command that will let me launch Internet Explorer. However, I wish to close the small command prompt that shows up when I launch IE. How can I do this? This is my current code:

我创建了一个小命令,可以让我启动 Internet Explorer。但是,我希望关闭启动 IE 时显示的小命令提示符。我怎样才能做到这一点?这是我当前的代码:

"%ProgramFiles%\Internet
Explorer\iexplore.exe"
http://localhost/test.html
PAUSE

I am guessing if I take out the Pause. It will close the CMD box upon closing IE??

我猜我是否取消了暂停。它会在关闭 IE 时关闭 CMD 框?

Also is there another command that I can use to simply create a command that will let me add something to the Menu with a small icon, which in turn runs the above. Is this complicated? Any tutorials I can use?

还有另一个命令我可以用来简单地创建一个命令,让我用一个小图标向菜单添加一些东西,然后运行上面的。这很复杂吗?我可以使用任何教程吗?

Thanks all

谢谢大家

回答by Dirk Vollmar

Use the startcommand:

使用start命令:

start "title" "%ProgramFiles%\Internet Explorer\iexplore.exe" http://www.example.com

回答by Russ Cam

you need this on the end

你最后需要这个

&& exit

For example

例如

"%ProgramFiles%\Internet Explorer\iexplore.exe" http://google.co.uk && exit 

回答by Anders

@echo off
start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" "http://www.example.com"
exit /b

But you really should not force IE, but use the default browser:

但是你真的不应该强制IE,而是使用默认浏览器:

@echo off
start http://www.example.com
exit /b

exit /b does not work on win9x IIRC, so if you need to support every version of windows andclose the terminal window if the user double clicks your batch file, go with:

exit /b 在 win9x IIRC 上不起作用,因此如果您需要支持每个版本的 Windows在用户双击您的批处理文件时关闭终端窗口,请使用:

@echo off
start http://www.example.com
cls

回答by Janac Meena

You can also launch your program with the /cswitch, which terminates the cmd once its finished executing

您还可以使用/c开关启动您的程序,该开关在完成执行后终止 cmd

for example

例如

cmd /c "%ProgramFiles%\InternetExplorer\iexplore.exe" http://localhost/test.html

回答by svens

You have to add 'start' in front of every program you launch, elsewhere your script is going to wait until it's finished.

您必须在启动的每个程序前添加“开始”,在其他地方您的脚本将等待它完成。