Search code examples
vbscriptbatch-filecmd

Scripts for security permissions


I want to write two scripts. They can be VBS or Windows commands.

The first one is for setting a user permission for a folder – the equivalent to a right click on a folder, properties, security, edit, add, NT AUTHORITY\NETWORK SERVICE.

The second one is for setting a permission to run as a service – the equivalent clicks are Control Panel / Administrative Tools / Local Security Policy, next on left side Local Policies / User Rights Assignment, then on right side Log on as a service -> add Network Service as a user that has the required privileges.


Solution

  • ms dos commands:

    Folder permission:

    CACLS path_of_folder /E /T /C /G "userName":F
    

    cacls command details

    Log on as a service permission:

    ntrights -u "userName" +r SeServiceLogonRight
    

    ntrights command details