Never been to DZone Snippets before?

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

Automatically restarting an application in Windows (See related posts)

This script will start a program and automatically relaunch it if it closes. It's a stripped down version of the script in JSI Tip 9635: How can I start an application, and automatically restart it if the user ends it?.

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


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

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts