We have a service that runs with different names on different machines like
Bomgar-scadsadccd, Bomgarsdscchfn, Bomgarscnkfkdk
So, here we need to write a VB script that will find this service with partial name "Bomgar" and check it's status like
1) Not present, then should install from a shared folder like "start \10.216.16.245\Bomgar.exe"
2) Installed but not running, then start the service.
3) Installed and running then quit.
How can we achieve this? This is what i have tried..
"strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service
where Name='bomgar*'")
nItems = colRunningServices.Count
If nItems > 0 Then
For Each objItem in colRunningServices
If objItem.State = "Stopped" Then objItem.startservice
ElseIf objItem.State = "Running" Then exit
End If
Next
Else
start \\10.18.23.245\Shared\Bomgar.exe
End If