Public Function StartService(ServiceName As String) As Boolean
Dim oSysInfo As New ActiveDs.WinNTSystemInfo
Dim oComp As ActiveDs.IADsComputer
Dim oSvcOp As ActiveDs.IADsServiceOperations
Dim sCompName As String
Dim sSvc As String
Dim lRet As Boolean
On Error GoTo errorhandler:
sSvc = ServiceName
sCompName = "WinNT://" & _
oSysInfo.ComputerName & ",computer"
Set oComp = GetObject(sCompName)
Set oSvcOp = oComp.GetObject("Service", sSvc)
oSvcOp.Start
StartService = True
Exit Function
errorhandler:
StartService = False
End Function
Public Function StopService(ServiceName As String) As Boolean
Dim oSysInfo As New ActiveDs.WinNTSystemInfo
Dim oComp As ActiveDs.IADsComputer
Dim oSvcOp As ActiveDs.IADsServiceOperations
Dim sCompName As String
Dim sSvc As String
Dim lRet As Boolean
On Error GoTo errorhandler:
sSvc = ServiceName
sCompName = "WinNT://" & _
oSysInfo.ComputerName & ",computer"
Set oComp = GetObject(sCompName)
Set oSvcOp = oComp.GetObject("Service", sSvc)
oSvcOp.Stop
StopService = True
Exit Function
errorhandler:
StopService = False
End Function
Public Function PauseService(ServiceName As String) As Boolean
Dim oSysInfo As New ActiveDs.WinNTSystemInfo
Dim oComp As ActiveDs.IADsComputer
Dim oSvcOp As ActiveDs.IADsServiceOperations
Dim sCompName As String
Dim sSvc As String
Dim lRet As Boolean
On Error GoTo errorhandler:
sSvc = ServiceName
sCompName = "WinNT://" & _
oSysInfo.ComputerName & ",computer"
Set oComp = GetObject(sCompName)
Set oSvcOp = oComp.GetObject("Service", sSvc)
oSvcOp.Pause
PauseService = True
Exit Function
errorhandler:
PauseService = False
End Function