Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

[RESOLVED]Check running program, start if not running VBscript.

$
0
0
Hello!

First of all, im totaly new to this and i dont know if im posting this in the right forum. Admin can delete/move this post if it's in the wrong place.

I have a Windows 2000 server (Yes i know it's lighyears old but i ) where i run 2 small programs that collects data from different places.
One of those programs chrashes 2-3 times a month and therefore i was looking after a script that could check if the program is running and run it if it isnt. :)
Easy as pie, so I thought.
Googled alot after different script, all that i found and tried got me different error messages and didnt work in Win 2000, most of them worked on my Win10 PC.
Then I foudn this VBscript that didn't produce any error instead nothing happened. so i thought maybe this could work if it just got modified a bit?
And that is why I need your help here guys, is it possible to manage this in Win2000 ?

Script:

Dim objWMIService, colItems, objItem, strComputer, strFlashEXEFile
Dim count

strFlashEXEFileName = "BarkStat.exe"
strFlashEXEFilePath = "C:\BarkStat\BarkStat" & strFlashEXEFileName
strComputer = "."

Set objWMIService = GetObject("winmgmts:" & strComputer & "\root\cimv2")
Set colItems = objWMIService.InstancesOf("Win32_Process")

count = 0

For Each objItem In colItems
If objItem.Name = strFlashEXEFileName Then
count = count + 1
Else
End If
Next

Set objWMIService = Nothing
Set colItems = Nothing

If count = 0 Then

Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
Return = oShell.run(strFlashEXEFilePath,3, false)
Set oShell = Nothing

End If

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>