Created
February 2, 2014 13:26
-
-
Save DamianFlynn/8768328 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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