I am looking for a command in cmd that will deny access to a certain folder to all users except for a specific one. I've tried with icacls
but I couldn't do that.
This is possible and can be done with the cacls
command in cmd:
for %A IN ("user1" "user2" "user3" "user4") do @cacls C:\some\folder /e /c /d %~A
where to allow access to these users to a certain folder again use:
for %A IN ("user1" "user2" "user3" "user4") do @cacls C:\some\folder /e /c /d %~A:f
Be sure to replace user1
, user2
, e.t.c. with the actual, correct usernames and add more if you want. You will need also to change C:\some\folder
to the actual folder path.
For a batch-file solution, double the percent-signs like this:
@for %%A IN ("user1" "user2" "user3" "user4") do @cacls C:\some\folder /e /c /d %%~A:f