Techtools.us
Menu

Automatically Restart A Program That Crashes

3/27/2018

0 Comments

 
Do you have a program that you want to be running all the time?  I found this batch somewhere on the web.  Props to whoever you are... 

Yes - I am aware you can do this with Task Scheduler as well.  I like a batch in the startup folder just fine.  Simple.  No fuss.

I had an issue with a file syncing program that should always be running (dropbox client).  It crashes sometimes, and files fail to mirror to the cloud.  Not good.  So, here's a vbs to keep an eye on something you want to run all the time (it doesn't have to be dropbox).  If the program you're watching ever crashes, this batch will restart it automatically.  You can even custom set a timed pause in case of a Windows update or whatever.  In this example, I have it set to 600000 milliseconds - which equals 10 minutes.  That part is at the end of the batch.  Set it to your desired time.  Replace what's in blue according to what program you'd like to keep going.  Note: Keep the the quotes in the batch:


​set Service = GetObject ("winmgmts:")
set Shell = WScript.CreateObject("WScript.Shell")

sEXEName = "program.exe"
sApplicationPath = "C:\Program Location\Program.exe\"

'Loop until the system is shutdown or user logs out
while true
 bRunning = false

 'Look for our application. Set the flag bRunning = true
 'If we see that it is running

 for each Process in Service.InstancesOf ("Win32_Process")
  if Process.Name = "program.exe" then
   bRunning=true
  End If
 next

'Is our app running?

if (not bRunning) then
 'No it is not, launch it
 Shell.Run Chr(34) & sApplicationPath & sEXEName & Chr(34)
end if

'Sleep a while so we do not hog the cpu
WScript.Sleep(600000)

wend
0 Comments



Leave a Reply.

    TechTools IT Consultants - Located in Little Rock, AR.

    Domain Migrations
    Data Center Infrastructure
    Systems Administration
    Network Administration
    Data Security
    Cabling
    Cloud Services
    Azure
    AWS
    Email
    Website Creation
    VPN
    Microsoft O365
    Microsoft Office
    Linux
    Network Security
    Data Forensics
    Network Monitoring
    Training
    Wireless
    Microsoft/Linux Server
    Phone Systems
    Electronic Medical Record Systems
    AntiVirus/AntiMalware
    VOIP
    Data Syncrhonization & Backup
    Etc, Etc, Etc


    Archives

    August 2019
    July 2019
    June 2019
    January 2019
    July 2018
    March 2018


    Categories

    All


    RSS Feed

Powered by Create your own unique website with customizable templates.
  • Techtools Blog
  • Tech News
  • Contact
  • Techtools Blog
  • Tech News
  • Contact