What is wrong with my script???

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
christsreturn
Posts: 2
Joined: 15 Aug 2012 13:15

What is wrong with my script???

#1 Post by christsreturn » 15 Aug 2012 13:20

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

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: What is wrong with my script???

#2 Post by dbenham » 15 Aug 2012 15:36

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

christsreturn
Posts: 2
Joined: 15 Aug 2012 13:15

Re: What is wrong with my script???

#3 Post by christsreturn » 16 Aug 2012 07:37

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

Post Reply