DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Automatically Restarting An Application In Windows

  • submit to reddit
        This script will start a program and automatically relaunch it if it closes.  It's a stripped down version of the script in <a href="">JSI Tip 9635: How can I start an application, and automatically restart it if the user ends it?</a>.

Set WshShell = CreateObject("WScript.Shell")
Do While True
 WshShell.Run """<the path to the executable file>""", 1, True

The pairs of double quotes inside the quoted string prevent "file not found" errors if the path contains spaces.  The Run method is documented <a href="">here</a>, in case you want to change the window style (the second argument).