DosTips.com

A Forum all about DOS Batch
It is currently 01 Oct 2016 16:14

All times are UTC-06:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 15 Aug 2012 13:20 
Offline

Joined: 15 Aug 2012 13:15
Posts: 2
Code:
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:
------------ 
***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


Top
   
PostPosted: 15 Aug 2012 15:36 
Offline
Expert

Joined: 12 Feb 2011 21:02
Posts: 1719
Location: United States (east coast)
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:
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


Top
   
PostPosted: 16 Aug 2012 07:37 
Offline

Joined: 15 Aug 2012 13:15
Posts: 2
Quote:
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited