I have a batch file that does the following:
@IF EXIST "C:\Program Files\MyAppFolder" (
icacls "C:\Program Files\MyAppFolder" /inheritance:r
icacls "C:\Program Files\MyAppFolder" /GRANT SYSTEM:(CI)(OI)(F)
icacls "C:\Program Files\MyAppFolder" /GRANT Administrators:(CI)(OI)(F)
)
Individually the commands work fine but put together like this in an IF statement I get this error and the script stops in its tracks:
(OI)(F) was unexpected at this time.
If I just have a single command in the IF statement then it works fine.
I'm guessing that you're only permitted one statement between the IF parenthesis?
This happens on Windows 2008 and Windows 2003 (with the ICACLS hotfix).