Question Locked

How do I use a variable in icacls.exe for the username

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am writing a script to change the ntfs security on hundreds of folders on Windows Server 2008. I need to be able to use the icacls.exe with a variable in place of the username in the /grant:r switch. I have tested this and tried numerous things over the past few days and now am at a critical time where I need to get this resolved. I have searched numerous forums online and have come up empty handed. Please help! Tell me if there is a way to do what I need to do or if I am dreaming!!

3 replies

by john.light

set userv=auserid
icacls c:\dir\tochange /grant:r %userv%:(OI)(CI)(IO)RX

by blackepyon01

I'm also re-doing my user creation script. Originaly, I made my script for Server2003 and used Cacls for the permissions. I'm currently trying to figure out syntax for ICACLS as I had it for CACLS (haven't had any luck with CACLS on Server2008).

Have you tried Cacls, or are you just trying to go with ICacls?

I will say one thing about variables in scrips, and that is to mind your quotations. Quote the command, unquote the variable and put ampersand before and after, quote again for switches.

This discussion is closed to new replies.