title: File Permissions using batch file
body: <p>This is my script.</p>
  
  <pre><code>@echo off
  
  set USER = %1
  
  if [%1]==[] goto error
  
  icacls \\TESTSERVER\testusers\%user% /grant:r "%USER%":(OI)(CI)F
  
  icacls d:\testusers\%user% /grant:r "%USER%":(OI)(CI)F
  
  @echo Folder Permission set successfully
  
  goto end
  
  :error
  
   @echo Error 101- Username Parameter invalid-Please provide a valid username as Parameter
  
  :end
  </code></pre>
  
  <p>And this is the output:</p>
  
  <pre><code>processed file: \\TESTSERVER\testusers\
  Successfully processed 1 files; Failed processing 0 files
  processed file: d:\testusers\
  Successfully processed 1 files; Failed processing 0 files
  Folder Permission set successfully
  </code></pre>
  
  <p>Instead of applying permissions to folder specified by user, the script is applying permission to parent folder.</p>
  
  <p>also when I see the security tab of testuser folder instead of user name I find some account name S-1-5-21-710178827-4191585984.....</p>
  
  <p>What am I doing wrong.</p>