Open and Wait untill IE is closed in batch file

前端 未结 4 539
猫巷女王i
猫巷女王i 2020-12-04 00:57

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 workin

相关标签:
4条回答
  • 2020-12-04 01:27
    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.......

    0 讨论(0)
  • 2020-12-04 01:29

    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"
    
    0 讨论(0)
  • 2020-12-04 01:41

    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
    
    0 讨论(0)
  • 2020-12-04 01:42
    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
    
    0 讨论(0)
提交回复
热议问题