How to Use CACLS.EXE in a Batch File

Last reviewed: September 23, 1996
Article ID: Q135268
The information in this article applies to:
  • Microsoft Windows NT Workstation versions 3.5 and 3.51
  • Microsoft Windows NT Server versions 3.5 and 3.51

The CACLS.EXE command line utility does not provide a /Y switch that automatically answers with Y for Yes to the ARE YOU SURE? Y/N prompt. However, you can use the echo command to pipe the character Y as input to the ARE YOU SURE? Y/N prompt when you call CACLS.EXE in a batch file.

To programmatically answer with Yes to the ARE YOU SURE? Y/N prompt during batch file execution, use the following command line in your batch file:

   echo y| cacls <filename> /g <username>:<permission>

NOTE: Do not type a space between the "y" and the pipe symbol (|), otherwise, CACLS.EXE fails to make the permission changes.


KBCategory: kbgeneral
KBSubcategory: ntgeneral nthowto
Additional reference words: prodnt 3.50 3.51 bypass skip confirmation
vertical bar


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 23, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.