Skip to content

Instantly share code, notes, and snippets.

@DamianFlynn
Created February 2, 2014 13:26
Show Gist options
  • Select an option

  • Save DamianFlynn/8768328 to your computer and use it in GitHub Desktop.

Select an option

Save DamianFlynn/8768328 to your computer and use it in GitHub Desktop.
Function Online()
Dim objWmiProvider
Dim objService
Dim strServiceState
Dim iResponse
'Check to see if the service is running
set objWmiProvider = GetObject("winmgmts:/root/cimv2")
set objService = objWmiProvider.get("win32_service='FIMSynchronizationService'")
strServiceState = objService.state
If ucase(strServiceState) = "RUNNING" Then
Online = true
Else
'If the service is not running, try to start it
response = objService.StartService()
'response = 0 or 10 indicates that the request to start was accepted
If ( iResponse <> 0 ) and ( iResponse <> 10 ) Then
Online = False
Else
Online = true
End If
End If
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment