GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

Min permission to restart a service on server

Home Forums Server Operating Systems Windows Server 2008 / 2008 R2 Min permission to restart a service on server

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    jwc1972
    Member
    #158133

    hello

    I would like to grant a domain user access to start, stop and restart a service on a remote computer running a batch file. When she runs this file from her PC she get access denied. Does she need to be a power user or an administrator on the server?

    option explicit
    Dim cimv2, oService, Result , strComputer,strServiceName
    strComputer = “192.168.1.*” ‘ Local Computer
    strServiceName = “sage200” ‘ sage Service om remote service
    ‘Get the WMI administration object
    Set cimv2 = GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _
    strComputer & “rootcimv2”)
    ‘Get the service object
    Set oService = cimv2.Get(“Win32_Service.Name='” & strServiceName & “‘”)

    ‘Path = “winmgmts:{impersonationLevel=impersonate}!\” & strComputer & _
    ‘ “rootcimv2:Win32_Service.Name='” & strServiceName & “‘”
    ‘Get the WMI administration object of the service
    ‘Set oService = GetObject(Path)
    ‘Check base properties
    If oService.Started Then
    ‘ the service is Not started
    wscript.echo “The service ” & strServiceName & ” is all ready running.”
    Else
    ‘ Start the service
    oService.StartService
    wscript.echo “Start ” & strServiceName & ” is Now running:”
    End If

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.