What are the minimum permissions a user would need to remotely restart a
service using vbs?
Of course everything works great if the user is a local administrator on the
remote machine, but that would go outside the parameters of the task.
I have given the user power user membership as well as full rights to the
Root namespace and all subnamespaces on the remote machine ... but with no
luck.
The remote machine is a Windows 2000 Server SP3
The funny thing is that power user rights allows remote connection and
service restart using "Computer Management" console, but once again this
falls out of the tasks parameters for a one button remote service restart.
Here is the script I wrote for the task
strComputer = "MyServer"
strService = "MyService"
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
CheckErr "Connect to " & strComputer
Set colRunningServices = objWMIService.ExecQuery ("Select * from
Win32_Service where Name='" & strService & "'")
For Each objService in colRunningServices
objService.StopService()
CheckErr "Stop " & strService & " Service"
objService.StartService()
CheckErr "Start " & strService & " Service"
Wscript.quit 1
Next
Wscript.echo "Could not connect to the " & strService & " on " & strComputer
Function CheckErr(strDesc)
If Err.Number <> 0 Then
strMessage = "Script failed to " & strDesc & " 0x" & Hex(Err.Number)
If(Len(Err.Description) > 0) Then
strMessage = strMessage & chr(13) & "Err.Description: " &
Err.Description
End If
wscript.echo strMessage & chr(13) & date & " at " & time
Else
wscript.echo strDesc & " successful
End If
End Function
Any help is greatly appreciated
TIA
Charles