Click here to Skip to main content
12,399,975 members (46,478 online)
Rate this:
Please Sign up or sign in to vote.
See more: VBScript batch script
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 12-Dec-11 4:32am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can write such scripts using the utility CACLS.EXE, here is the help on it:[^].

Alternatively, run
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.

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 13 Dec 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100