JSI Tip 3897. How do I script the right for a user to manage all Windows 2000 services?

Jerold Schulman

July 11, 2001

1 Min Read
ITPro Today logo in a gray background | ITPro Today


In tip 3896, we learned how to use SUBINACL to grant a user the right to manage a service.

If you wish to grant the right to manage all services on a computer, copy/paste the following to SvcGrant.vbs:

jsiDomain= Wscript.Arguments.Item(0)'domain of computer accountjsiComputer = Wscript.Arguments.Item(1)'netbios ComputerNamejsiUserName = Wscript.Arguments.Item(2)'UserName (in the domain)jsiPerm= Wscript.Arguments.Item(3)'access code'bind to ComputerNameset objTarget = GetObject("WinNT://" & jsiDomain & "/" & jsiComputer & ",computer")'create a shell object for call to subinaclset objCMD = CreateObject("Wscript.Shell")'get list of servicesobjTarget.filter = Array("Service")For each Service in objTargetcommand = "subinacl /service " & Service.name & " /grant=" & jsiUserName & "=" & jsiPermobjCMD.Run command, 0'report the servicesWscript.Echo "User granted access to " & Service.name & " "next

NOTE: This script does NOT perform any error checking.

To run the script:

CSCRIPT FolderSvcgrant.vbs DomainName ComputerName UserName Access

Example:

CSCRIPT C:UtilSvcgrant.vbs JSIINC JSI015 Jennifer F

The above displays:

Microsoft (R) Windows Script Host Version 5.1 for WindowsCopyright (C) Microsoft Corporation 1996-1999. All rights reserved.User granted access to AlerterUser granted access to AppMgmt. . .. . .User granted access to W32TimeUser granted access to W3SVCUser granted access to WinMgmtUser granted access to WMDM PMSP ServiceUser granted access to Wmi

NOTE: If you don't want the display, remove the following from the script:

'report the services
Wscript.Echo "User granted access to " & Service.name & " "



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like