问题
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
回答1:
Use the start
command:
start "title" "%ProgramFiles%\Internet Explorer\iexplore.exe" http://www.example.com
回答2:
you need this on the end
&& exit
For example
"%ProgramFiles%\Internet Explorer\iexplore.exe" http://google.co.uk && exit
回答3:
@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
回答4:
You have to add 'start' in front of every program you launch, elsewhere your script is going to wait until it's finished.
回答5:
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
来源:https://stackoverflow.com/questions/1522725/cmd-script-how-to-close-the-cmd