• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 724
  • Last Modified:

How to add Privileges via commandline

I would like to know how to add the following Privileges via bat script or vbscript:


I have tried manually adding the group policies, saving them off and then copying in the script.  NTRights.exe is not available after 2003.  I have performed a registry diff to see what registry keyes are alter but these settings are not stored in the registry.
1 Solution
Sure it doesn't work? I ran through a quick test and it processed it... Just had top copy it over..... Seen various reports online previously that it worked through 2008.....
daOracleAuthor Commented:
NTRights.exe works on Windows 7.  I am not allow to distribute the executable due to licensing issues.  I am creating an installer of our software.

Don't know of another method to do this..... I would request attention above to get added to the MS programming Topic Areas. Perhaps an API based method?
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Hi daOracle,
I was pointed to your question not that long ago. To answer your question about adding privileges to your installation using a scripting method you can use SWbemLocator.Security_ object through WMI API simply by using this example.

'This example uses impersonation and assigns privileges to the operation and 
'verifies privileges are assigned properly. If not nothing will be run by WMI.
strComputer = "."
Set objSWbemServices = GetObject ("winmgmts:{impersonationLevel=impersonate, (Security, Debug, Restore, Backup)}!" & "\\" & strComputer & "\root\cimv2")

'create security object 
Set objSWbemPrivileges = _
'Count actively assigned privileges to verifiy there assigned correctly. 
'0 Entrys = 0 assigned. Simple. This example outputs 4 as 4 are assigned.
WScript.Echo "WMI privilege count: " _
    & objSWbemPrivileges.Count

Open in new window

If you would like to see a full list of privilegs and if they are enabled you can use this example.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" _
    & strComputer & "\root\cimv2")
set colPrivileges = objWMIService.Security_.Privileges
For I = 1 To 27
' Display information about each privilege 
For Each objItem In colPrivileges
wscript.echo objItem.Identifier & vbtab & objItem.Name _
    & vbtab & objItem.Displayname _
    & vbtab & "Enabled = " & objItem.IsEnabled

Open in new window

You can also add your privileges after the initial logon to WMI.
Set Service = GetObject( _
Service.Security_.Privileges.AddAsString "SeDebugPrivilege", True

Open in new window

If you have questions on implementation you can reference these MSDN links.
Privilege Constants
Executing Privileged Operations Using VBScript
I gave daOracle the answer to add the privileges via vbscript. No response was given. I usually program these tasks in c++ but it is possible through WMI like the example shown above.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now