How To Prevent Internet Explorer From Closing

Sometimes you might want to prevent users closing Internet Explorer, in a kiosk environment for example. To prevent internet explorer from closing you will need to create two scripts. the first is a batch file to open IE and reopen it when users close it. The second is to launch the first script in a way that is hidden from users (to prevent them from closing it). These scripts can be put in a users login script or distributed via group policy.

A Script To Open IE After Closing

The first script is a batch file to open IE and reopen it if a user closes it. Put the following code into a text file and save it as a .bat file:

:start
“C:\Program Files\Internet Explorer\iexplore.exe” <URL>
goto start

The <URL> is optional and specifies the url to go to when IE starts. There are other switches you can add to this command, for example to start ie in kiosk mode. When you run this script, it opens Internet Explorer and waits for it to close. After closing Internet Explorer, the script continues by going back to the start and launching Internet Explorer again. The only way to break the cycle is to close the batch script that is preventing ie from closing permenantly.

A Script To Hide The Batch File

To prevent users from closing the batch script that opens Internet Explorer, you need a vbs script that runs, starts the batch script in hidden mode and closes itself.

Copy the below code into a text file with a .vbs extention, specifying the batch file you created:

Set oShell = CreateObject (“Wscript.Shell”)
Dim strArgs
strArgs = “cmd /c %LOGONSERVER%\Login Scripts\Script To Open IE After Closing.bat”
oShell.Run strArgs, 0, false

Obviously you have to put these files in locations that the user has access to and to truely prevent users to closing Internet Explorer, you need to deny them access to the Task Manager so they can’t kill the scripts that prevent IE from closing. You can do this with group policy.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

2 thoughts on “How To Prevent Internet Explorer From Closing

  1. wont that script spam internet explorer?

    also if you use …iexplore.exe” -k it will open in kiosk mode (full screen without any toolbars or the address bar, can still close by using ALT-F4)

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Yup, you can close it with Alt+F4, but it’s just going to start another IE. Yes, typically this is used with the -k switch for IE kiosk mode 😉

      VN:F [1.9.22_1171]
      Rating: 0 (from 0 votes)

Leave a comment

Your email address will not be published. Required fields are marked *