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

By sarah.peterson ·
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!!

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

like this

by john.light In reply to How do I use a variable i ...

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

Collapse -

same boat

by blackepyon01 In reply to How do I use a variable i ...

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 Server200.

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.

Related Discussions

Related Forums