Menu
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 Archives
August 2019
Categories |