Open and Wait until IE is closed in batch file

I want to open IE from a batch file and wait until it is closed before moving on to the next line of the batch file. How to do it? BTW iexplore command doesn't seem to work in Windows 7 command prompt. Any idea why?

Thank...

+1


source to share


4 answers


Browsers are tricky when it comes to lifespan, even in the days when IE could open multiple windows in front of tabs in the same process. They also often use DDE to open URLs, making it difficult to track the "correct" process. If you want to force the user to use IE (why not use the default browser?) You could use a Windows scripting host to automate IE (Automation has some issues when it comes to IIRC protected IE)

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

      

+1


source


Other methods work here if Internet Explorer is not running.

If IE is already working, this will not work correctly. This is, of course, awful if the 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"

      

+3


source


start /wait whatever.exe

      

The flag /wait

will make the start wait until the program is closed before it returns.

As for the fact that iexplore doesn't work, you are correct. This is curious ... However, you can still call it with the full path:

start "" /wait "c:\Program Files\Internet Explorer\iexplore.exe" http://stackoverflow.com

      

I have updated the second command line to work around some error in command handling start

. This is strange. However, the correct way to do it is:

start /wait http://address.com

      

+1


source


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 great.

check the code before posting ur comments ........

-2


source







All Articles