Check if program is running

I was having trouble with my solar monitoring software closing down at random for no apparent reason every three to seven days, I was unable to find any pattern to this behavior.

To solve the problem I scheduled this vbscript to run every hour. I did not write it from scratch, I used examples to get the result you see here. The script looks for the program by name and starts the program if it’s not running. I have changed the script to notepad.exe for testing, change it to whatever your program name is.

The program I am using is SG-View.exe from solar-guppy. My solar hardware consists of 16 x 185 watt panels, a Xantrex T 2.8 inverter and an old laptop with a serial port. SG-View.exe is the program that collects the data from the inverter. The data is then uploaded to

There are some lines you will want to comment out once you are sure its working, like this message box Msgbox(“Notepad is not running, I will start it now”) it is only there for testing (put a ‘ in front of the line to comment it out).

'Msgbox("Notepad is not running, I will start it now")

Copy this code, open notepad paste it and save it as filename.vbs where filename is what ever you want to call it.

'Check if a program is running, if not run it.
Set WshShell = WScript.CreateObject ("WScript.Shell")
Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")
For Each objProcess in colProcessList
If = "notepad.exe" then
vFound = True
End if
If vFound = True then
'WshShell.Run ("C:\Windows\system32\cmd.exe")
'Add sleep if needed
wscript.sleep 50
'send keys and kill taskin needed
'WshShell.sendkeys "taskkill /IM notepad.exe"
'wscript.sleep 50
'WshShell.SendKeys "{ENTER}"
Msgbox("Notepad It is already running, nothing to do")
Msgbox("Notepad is not running, I will start it now")

sub shell(cmd)
' Run a command as if you were running from the command line
 dim objShell
 Set objShell = WScript.CreateObject( "WScript.Shell" )
 Set objShell = Nothing
end sub

shell "notepad.exe"

End If