Batch file IF statement fails with "was unexpected at this time"
The shell seems to think that the )
in the third line of your command is the closing parenthesis for the one opened in the first line. You need to quote the arguments containing parenthesis:
@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)"
)