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

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Automatically restarting an application in Windows

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).
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS