I want to create a batch file that applies permissions for a given user folder using icacls. This is the batch file I made:
@echo off
set / p username = Enter username:
echo Select permissions:
echo N - no access
echo F - full access
echo M - modify access
echo RX - read and exe
echo R - read-only acc
echo W - write-only ac
echo D - delete access
echo.
set / p perm = Enter permissions:
if% perm% == F
icacls "C: \ Users \% username%" / grant: r "% username% :( OI) (CI) F"
When I run this file and enter permissions as F, it displays this error : the command syntax is incorrect. but if I run the same command directly in cmd, it works fine. So, how do I fix a command in a batch file so that it runs without any problems?
source share