How to add Privileges via commandline

Posted on 2011-10-25
Last Modified: 2012-05-12
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.
Question by:daOracle
    LVL 66

    Expert Comment

    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.....

    Author Comment

    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.
    LVL 66

    Expert Comment


    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?
    LVL 15

    Accepted Solution

    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
    LVL 15

    Expert Comment

    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.
    LVL 59

    Expert Comment

    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 Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
    When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
    This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
    This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now