Page 1 of 1

What is wrong with my script???

Posted: 15 Aug 2012 13:20
by christsreturn

Code: Select all

REM Changes the permission of specified file to specified Access for specified group and logs the output.
echo ------------ >> %Output%
echo ***Change*** >> %Output%
echo ------------ >> %Output%
for /f "delims=" %%y in (%Input%) do (
echo icacls %%y /grant:r %Group%:(%Permission%) >> %Output%
icacls %%y /grant:r %Group%:(%Permission%) 2>> %Output%
)
echo. >> %Output%

And the output that gets displayed is:

Code: Select all

------------ 
***Change***
------------
icacls C:\Test_File.txt /grant:r EVERYONE:(F
icacls C:\Test_File_2.txt /grant:r EVERYONE:(F
%y: The system cannot find the file specified.


I can't figure out why it's not using the value from the file that it should be pulling.

Thanks for any help

Re: What is wrong with my script???

Posted: 15 Aug 2012 15:36
by dbenham
You have 2 places in your code where you have ) character that is not escaped and not quoted, so it is ending your code block prematurely.

You just need to escape the ) characters.

Code: Select all

REM Changes the permission of specified file to specified Access for specified group and logs the output.
echo ------------ >> %Output%
echo ***Change*** >> %Output%
echo ------------ >> %Output%
for /f "delims=" %%y in (%Input%) do (
  echo icacls %%y /grant:r %Group%:(%Permission%^) >> %Output%
  icacls %%y /grant:r %Group%:(%Permission%^) 2>> %Output%
)
echo. >> %Output%


Dave Benham

Re: What is wrong with my script???

Posted: 16 Aug 2012 07:37
by christsreturn
You have 2 places in your code where you have ) character that is not escaped and not quoted, so it is ending your code block prematurely.

You just need to escape the ) characters.



Thanks a lot! That solved my problem :D