Open and Wait untill IE is closed in batch file
I want to open IE from开发者_开发知识库 a batch file and wait untill it is closed before going to the next line of the batch file. How to do this? BTW iexplore command seems to be not working in Windows 7 command line. Any idea why?
Thanks...
The other methods here work if Internet Explorer isn't running.
If IE is already running though, it won't work properly. This is of course awful if a web page in IE is the starting vector for your script!
The fix I found is to use -noframemerging as a switch to iexplore.exe:
start "" /wait "%ProgramFiles%\Internet Explorer\iexplore.exe" -noframemerging "https://www.google.com"
Browsers are complicated when it comes to process lifetime, even back in the days before tabs, IE could have more than one window open in a single process. They also often use DDE to open urls making it hard to track the "correct" process. If you want to force the user to use IE (Why not use the default browser?) you could use windows scripting host to automate IE (Automation has some problems when it comes to protected IE IIRC)
I would recommend just a simple pause:
start /wait http://example.com
echo. When you are done reading xyz, press [Enter] to continue...
pause >nul
start /wait whatever.exe
The /wait
flag will make start wait until the program closes before it returns.
As for iexplore not working, you're right. That's curious... However, you can still invoke it with a full path:
start "" /wait "c:\Program Files\Internet Explorer\iexplore.exe" http://stackoverflow.com
I've updated the second command line to work around some manner of bug in start
's command processing. It's weird. However, the proper way to do this is:
start /wait http://address.com
call "C:\Program Files\Internet Explorer\iexplore.exe" www.google.com
call "C:\Program Files\Internet Explorer\iexplore.exe" www.stackoverflow.com
call "C:\Program Files\Internet Explorer\iexplore.exe" www.codeproject.com
echo done
pause
I tried it on windows 7 and it works perfectly....
test the code before posting ur comments.......
精彩评论