Dim oArgs
Set oArgs = WScript.Arguments
If oArgs.Count <> 1 Then
On Error Goto 0
Err.Raise 8, _
"VMware.View.Service.Start.Action.vbs", _
"Wrong number of arguments"
End If
Dim ServiceName
ServiceName = oArgs(0)
Dim oWmi
Set oWmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
If oWmi Is Nothing Then
On Error Goto 0
Err.Raise 10, _
"VMware.View.Service.Start.Action.vbs", _
"Unable to open WMI provider: winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2"
End If
Dim oServiceSet
Set oServiceSet = oWmi.ExecQuery("Select * from Win32_Service Where Name='" & ServiceName & "'")
If oServiceSet Is Nothing Or oServiceSet.Count < 1 Then
On Error Goto 0
Err.Raise 11, _
"VMware.View.Service.Start.Action.vbs", _
"Unable to find " & ServiceName & " service"
End If
WScript.Echo "Info: Starting " & ServiceName & " service..."
Dim oService
For Each oService in oServiceSet
oService.StartService
Next
WScript.Echo "Info: Started " & ServiceName & " service"