8

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
10

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:f

The CACLS command does not provide a /Y switch to automatically answer 'Y' to the Y/N prompt. However, you can pipe the 'Y' character into the CACLS command using ECHO, use the following syntax:

ECHO Y| CACLS filename /g username:permission

Source Cacls - Modify Access Control List - Windows CMD - SS64.com

7

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.