CMD Script: How to close the CMD

2020-07-10 07:16发布

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:

"%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??

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

5条回答
▲ chillily
2楼-- · 2020-07-10 07:16

Use the start command:

start "title" "%ProgramFiles%\Internet Explorer\iexplore.exe" http://www.example.com
查看更多
Rolldiameter
3楼-- · 2020-07-10 07:16

you need this on the end

&& exit

For example

"%ProgramFiles%\Internet Explorer\iexplore.exe" http://google.co.uk && exit 
查看更多
做自己的国王
4楼-- · 2020-07-10 07:20

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

查看更多
聊天终结者
5楼-- · 2020-07-10 07:21
@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:

@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 and close the terminal window if the user double clicks your batch file, go with:

@echo off
start http://www.example.com
cls
查看更多
你好瞎i
6楼-- · 2020-07-10 07:42

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

for example

cmd /c "%ProgramFiles%\InternetExplorer\iexplore.exe" http://localhost/test.html
查看更多
登录 后发表回答