Change file/directory permissions in Vista (icacls.exe) or XP (cacls.exe) using Nant

Cacls

To change the permissions on a file using Nant in windows XP use the cacls.exe utility

   1: cacls test /t /e /g everyone:c

test directory or file name
/t Change ACL’s of specified files in the current directory and all subdirectories
/e Edit ACL instead of replacing it.
/g Grant specified user access rights.
everyone user group
c Change (write)
Other rights are:
R Read
W Write
F Full control

To get all the information type “cacls /?” into the command prompt

The problem I found using this cacls in vista is there is a prompt asking (Y/N).

icacls – (Vista)

To solve this I used the icacls.exe

   1: iacls C:\ProgramData\MyApp /T /C (OI) (CI) /Grant Users:F

again use “icacls /?” to get all the information from the command prompt

Nant Call for icacls

   1: <target name="test">

   2:     <exec program="icacls" commandline="C:\ProgramData\MyApp /T /C (OI) (CI) /Grant Users:F" />

   3: </target>

Nant <exec>

cacls – resource link

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: