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:
“C:\Program Files\Internet Explorer\iexplore.exe” <URL>
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”)
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.