Batch file using icacls not executing

2

I'm reading the users from a file and I try to grant them access to a specific folder, but when I execute the batch file below nothing happens. Can someone please explain me what is wrong?

Edit: I'm using Windows Server 2012 R2.

This is the code within the file:

for /f %%i in (D:\Users\SBZ\DL_RO_SBZ_USERS.txt) do (
    icacls D:\Users\SBZ\%%i /grant %%i@domain.com:(OI)(CI)F /Q
)
pause

Thank you!

pinty

Posted 2015-08-28T11:03:54.780

Reputation: 21

1Welcome to Super User. This is a little vague. Please explain "nothing happens". Does that mean the batch file does not start, it gives an error, that specific for clause doesn't run, etc. If you are getting an error message, please quote it exactly as you see it. – CharlieRB – 2015-08-28T11:23:36.610

It means that the batch file does not start so I can't see any error or a clause message. – pinty – 2015-08-28T11:25:44.777

How are you running the file? Can you put an echo Hello World as the first line? – dsolimano – 2015-08-28T12:04:51.113

2Debugging your batch files – DavidPostill – 2015-08-28T12:15:59.833

Answers

0

The parentheses in your Icacls statement is setting off the loop I think. Try:

for /f %%i in (D:\Users\SBZ\DL_RO_SBZ_USERS.txt) do (
    icacls D:\Users\SBZ\%%i /grant %%i@domain.com:(OI^)(CI^)F /Q
)
pause

The ^ “escapes” the parentheses.

Mark Deven

Posted 2015-08-28T11:03:54.780

Reputation: 1 101