Ok, this vbscript show you how we can monitor some process if there aren't running like iexplore.exe , notepad.exe, and calc.exe
Check+RunApp.vbs
Option Explicit
If AppPrevInstance() Then
WScript.Echo "Instance already running"
WScript.Quit
Else
Do
Call Main(Array("%ProgramFiles%\Internet Explorer\iexplore","%windir%\system32\calc.exe","%windir%\system32\notepad.exe"))
'Pause 2 minutes
Call Pause(2)
Loop
End If
Sub Main(colProcessPaths)
Dim ProcessPath
For Each ProcessPath In colProcessPaths
CheckProcess(ProcessPath)
Next
End Sub
Sub CheckProcess(ProcessPath)
Dim ProcessName : ProcessName = StripProcPath(ProcessPath)
msgbox ProcessPath &vbcr& CommandLineLike(ProcessName) &vbcr& CommandLineLike("cmd /c " & chr(34) & ProcessPath & chr(34))
With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
With .ExecQuery("SELECT * FROM Win32_Process WHERE Name LIKE " & CommandLineLike(ProcessName) & " OR Commandline LIKE " & CommandLineLike("cmd /c " & chr(34) & ProcessPath & chr(34)))
If .Count = 0 Then
With CreateObject("WScript.Shell")
.Run DblQuote(ProcessPath)
End With
Else
Exit Sub
End if
End With
End With
End Sub
Function AppPrevInstance()
With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
With .ExecQuery("SELECT * FROM Win32_Process WHERE CommandLine LIKE " & CommandLineLike(WScript.ScriptName))
AppPrevInstance = (.Count > 1)
End With
End With
End Function
Sub Pause(Minutes)
Wscript.Sleep(Minutes*1000*60)
End Sub
Function StripProcPath(ProcessPath)
Dim arrStr : arrStr = Split(ProcessPath, "\")
StripProcPath = arrStr(UBound(arrStr))
End Function
Function CommandLineLike(ProcessPath)
ProcessPath = Replace(ProcessPath, "\", "\\")
CommandLineLike = "'%" & ProcessPath & "%'"
End Function
Function DblQuote(str)
DblQuote = chr(34) & str & chr(34)
End Function
For your case i will try to take a look on it or i will advise you where you can ask this kind of question, because i don't know it for the moment how your program work ?