I need help in setting permissions to files. I need to collect all files in %temp% and log them to a files.txt file and then need to change permission in files.txt and set it back to its original permissions.

any help is appreciated.
1 Comment   [ + ] Show Comment


  • I got it I used the below cmd lines and it worked for me thanks all for your suggestions.

    fpr /F "tokens=*" %%J in (%temp%\Dirlist.txt) do icacls "%%J" /grant BUILTIN\Users:(m)
Please log in to comment



Your request is a bit confusing.  Users have R/W access to the temp folder, so what has to be changed?  If you need to change file permissions from a CMD window, look into the ATTRIB command.

If you need to create a TXT file which contains the list of files in the folder, simply redirect the output of a DIR command into a file like so:

DIR *.* > %TEMP%\DirList.txt

Answered 09/21/2015 by: vjaneczko
Seventh Degree Black Belt

  • Yes you are right Users folder have R/W access but when I scan some users folder in our organization and we came to know that some of the files in %temp% folder does not have R/W access to other users except the users who created. so in order to modify that file I need to take over the rights on those files. So the first answer I got
    I can direct the output by this CMD DIR *.* > %TEMP%\DirList.txt and then how I can I change permissions in DirList.txt and then set it back to its original permissions.
Please log in to comment
If, by "permissions", you mean the ACLs, there are no native commands to deal with those. Obtain and use either SubInACL or, as I prefer, SetACL.
Answered 09/22/2015 by: VBScab
Red Belt

  • How can I setACL to all the files which are in only %TEMP%\DirList.txt
  • iCacls?
    • can you give an example how to set modify permission in "%temp%\DirList.txt'
      NOTE: need to give permission to the files which are in DirList.txt and not to DirList.txt
Please log in to comment
Capture this with RayPack , RayPack has the ability to capture Permission Changes on the target machine.
Very easy because you can now first make sure the permissions are set correctly and then finalize the capture.

download a free evaluation here: https://raypack.raynet.de/en/contact 

Answered 09/22/2015 by: jaybee96
Red Belt

Please log in to comment
>How can I setACL to all the files which are in only %TEMP%\Dirlist.txt?

You need to create a script but why bother, when your command line lists all files, i.e. *.*? And why do you need to change permissions back? Used correctly, SetACL adds the specified account to the ACL, it doesn't replace the existing permissions.
Answered 09/23/2015 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity