How to open and close Internet Explorer from a batch file?

I have a batch file that needs to start Internet Explorer and open www.google.com . When the whole page is loaded, it should kill the IE process i.e. Close all instances of IE on this system. My batch file has the following two lines.

iexplore.exe "www.google.com"
taskkill /IM iexplore.exe /F

      

But after loading it doesn't close the IE instance.

If I have a separate batch file with a single line taskkill / iexplore.exe the IM / the F . This batch file closes the IE instance.

What happens in the first batch file.

The PS password file is located in the Internet Explorer program files folder.

+3


source to share


1 answer


I don't exactly understand your purpose to open and close Internet Explorer immediately? but here's a sleep example to show you how it works!

@echo off
Title Start and Kill Internet Explorer
Mode con cols=75 lines=5 & color 0B
echo(
echo                     Launching Internet Explorer ...
Start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" "www.google.com"
:: Sleep for 20 seconds
Timeout /T 20 /NoBreak>NUL
echo(
echo            Hit any Key to kill all instances of Internet Explorer
Pause>nul
Cls & Color 0C
echo(
echo              Killing Internet Explorer Please wait for a while ...
Taskkill /IM "iexplore.exe" /F
pause

      

And if you want to see more options like how to start a process and how to kill one process or multiple processes at the same time that interact with user input with a dynamic menu, you should take a look at this post ==> How to check and fix user input when it omits the .exe extension to kill the process?



Try this alternative without user confirmation:

@echo off
Title Start and Kill Internet Explorer
Mode con cols=75 lines=5 & color 0B
echo(
echo                     Launching Internet Explorer ...
Start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" "www.google.com"
:: Sleep for 10 seconds, you can change the SleepTime variable
set SleepTime=10
Timeout /T %SleepTime% /NoBreak>NUL
Cls & Color 0C
echo(
echo              Killing Internet Explorer Please wait for a while ...
Taskkill /IM "iexplore.exe" /F

      

+6


source







All Articles