Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I want to write two scripts, they can be vbs or ms-dos commands.

First is setting a user permission for a folder (the equivalent to: right click on a folder, properties, security, edit, add, NT AUTHORITY\NETWORK SERVICE).

Second is to set a permision to run as a service, the equivalent click click is: Control Panel / Administrative Tools / Local Security Policy; left side: Local Policies / User Rights Assignment; right side: Log on as a service -> add Network Service as a user that has rights.

Would somebody help me to do that please?
Posted

thanks for answer!

the commands I used are:
folder permission:
CACLS path_of_folder /E /T /C /G "userName":F

log on as a service permission:
ntrights -u "userName" +r SeServiceLogonRight


Here you can find ntrights description
 
Share this answer
 
You can write such scripts using the utility CACLS.EXE, here is the help on it: http://ss64.com/nt/cacls.html[^].

Alternatively, run
CACLS > cacls.help.txt
to obtain the text file with the options of the utility currently available in your system.

Needless to say, the account on which your batch script is executed should have enough permission to modify the permissions in questions. You can check this in UI using the properties dialog of the file system object you are interested in.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900