Bypass the cacls confirmation prompt automatically?
Olivia Zamora
I'm working on a custom settings script for Windows that will automate specific settings I want on a new Windows machine or installation. I grant access to some folders using cacls in my script, but I am prompted with the Y/N prompt for each listed item. I would like to bypass this by automatically saying "yes" for each folder or file I specify. I am aware of the risks with this and have had no issues thus far. Here is an example of one such directory in my script:
cacls "%PROGRAMFILES%\WindowsApps" /grant Administrators:f 3 Answers
I am prompted with the Y/N on each item
I would like to bypass this by automatically saying "yes" for each of these
You can pipe Y into cacls using echo:
echo Y | cacls "%PROGRAMFILES%\WindowsApps" /grant Administrators:fThe
CACLScommand does not provide a/Yswitch to automatically answer'Y'to theY/Nprompt. However, you can pipe the'Y'character into theCACLScommand usingECHO, use the following syntax:ECHO Y| CACLS filename /g username:permission
Source Cacls - Modify Access Control List - Windows CMD - SS64.com
Use this syntax:
echo y| cacls.exe [options]...Note that the command-line needs to be written exactly as above, including the blanks (see link).
Switch to icacls.exe (built into Windows), which doesn't have this prompt.