Zaslßnφ p°φkazu slu₧b∞

Postup:
Private Enum CommandOpConstants
    cocStart = 1
    cocStop
    cocPause
    cocContinue
End Enum

' Start, Stop, Pause nebo Continue p°φkazy pro slu₧bu pomocφ Active Directory
' Vracφ True p°i ·sp∞ÜnΘm provedenφ
'
' POZN┴MKA: Je nutnß reference na the Active DS Type Library

Function ServiceCommand(ByVal ServiceName As String, _
    ByVal CommandOp As CommandOpConstants) As Boolean

    Dim thisComputer As ActiveDs.IADsComputer
    Dim thisService As ActiveDs.IADsServiceOperations
    Dim sysInfo As New ActiveDs.WinNTSystemInfo
    
    On Error Resume Next
   
    Set thisComputer = GetObject("WinNT://" & sysInfo.ComputerName & _
        ",computer")
    Set thisService = thisComputer.GetObject("Service", ServiceName)
    
    Select Case CommandOp
        Case cocStart
            thisService.Start
        Case cocStop
            thisService.Stop
        Case cocPause
            thisService.Pause
        Case cocContinue
            thisService.Continue
    End Select
    
    ServiceCommand = (Err.Number = 0)

End Function

Zp∞t

Autor: The Bozena