Page 1 of 1

auto agree in using CACLS Command + Answer [solved]

Posted: 29 Oct 2011 01:39
by abc0502
i'm making 2 batch files to lock and unlock a folder using Cacls command like that:
The lock batch:

Code: Select all

cacls c:\myfolder /d Admin-PC


The Unlock batch:

Code: Select all

cacls c:\myfolder /P Admin-PC:F


i want to put that command in the patch file but it ask for yes or no
is there a way to put the answer with the command so i don't have to answer the question every time ... thanks

Re: The Answer is Very Easy

Posted: 29 Oct 2011 02:10
by abc0502
OK ... I found the Answer for that question in http://situsnya.wordpress.com/2008/08/31/caclsexe-display-or-modify-access-control-lists-acls-for-files-and-folders/

the batch file should look like that: (lock)

Code: Select all

@echo off
cls
echo Y| cacls c:\myfolder /d Admin-PC


the CACLS command doesn't come with the /Y option so we write the Y using ECHO

the Unlock Batch file:

Code: Select all

@echo off
cls
echo Y| cacls c:\myfolder /P Admin-PC:F

:D :lol: