Hi I am creating a script to decrypt all files in C:\ but unable to decrypt files which are marked as read only. So is there any script to decrypt read only files.
Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answer Chosen by the Author

3
you could try cmd line

attrib -R c:\* /S /D

Bat Example:
###########################
REM Find Read-Only Files
dir /AR /S /B c:\ >> c:\Myfile.txt

REM Uncheck Read-Only Flag
for /F "tokens=*" %%A in (c:\myfile.txt) do attrib -R "%%A"

REM DeCrypt Files
cipher.exe /D /A /S:C:\
cipher.exe /U /N >>"C:\Encrypted_Files-ONLY.log"

REM Set read-only flag:
for /F "tokens=*" %%A in (c:\myfile.txt) do attrib +R "%%A"
###########################

(Added quotes around the last %%A to handle spaces in the file paths)
Answered 08/04/2015 by: jleitsch
Orange Senior Belt

  • The files won't be read only then, which may defeat the purpose of what the OP is trying to achieve.
  • Thanks for the replay
    you cmd line sets read onlt to entire folder

    but I need a script to get all read only files from entire C:\ and then I need to uncheck ready only files and then do my work and then set it back to read only.

    any help should be appreciated.
    • Get all Read-only files and write them to a file:
      dir /AR /S /B c:\ >> c:\Myfile.txt

      For each file line in MyFile REMOVE read only tag:
      for /F "tokens=*" %%A in (c:\myfile.txt) do attrib -R "%%A"

      Run you decrypt

      For each file line in MyFile SET read only tag:
      for /F "tokens=*" %%A in (c:\myfile.txt) do attrib +R "%%A"
      • Thanks Jleitsch.... everything looks good but when I tried to uncheck/set flag it doesn't set flag when there are spaces between lines (EG: C:\Program Files-there is space between program and files) and it gives an error PARAMETER FORMAT NOT CORRECT - I guess we need to put double quotes between each line to pass this error. I tried this cmd by adding usebackq but still dosent work (for /F "usebackq tokens=*" %%A in (c:\myfile.txt) do attrib -R %%A). so is there any other cmd's or script to solve this.

        Thanks
      • Jleitsch.. I have 1 more question. I want to get all Read-only files except the C:\WINDOWS folder. so how can we do this. I don't want to touch windows folder. Is there any way to modify this cmd (dir /AR /S /B c:\ >> c:\Myfile.txt
        ) to skip C:\WINDOWS folder

        Thank you
    • Sorry Enthusiasm....I forgot the qoutes around the %%A in the attib cmd line. Should look like

      do attrib -R "%%A"
      do attrib +R "%%A"
      • Thank you so much Jleitsch... everything looks perfect. Thank you for your help :)
      • Jleitsch.. I have 1 more question. I want to get all Read-only files except the C:\WINDOWS folder. so how can we do this. I don't want to touch windows folder. Is there any way to modify this cmd (dir /AR /S /B c:\ >> c:\Myfile.txt
        ) to skip C:\WINDOWS folder

        Thank you
    • Changing the dir command to:
      dir /AR /S /B c:\ | findstr /v "\Windows" >> c:\MyFile.txt
      Will ignore the Windows Directory from listing read-only files
      • Thank you.....and I appreciate your quick response
      • Hi Jleitsch

        I need help in setting permissions to files. I need to collect all files in C:\ and log them to a files.txt file and change permission in files.txt and set it back to original permissions.

        any help is appreciated.
Please log in to comment

Answers

0
You'll need to supply for more information about the issue you're having to get any help.

What operating system are you working with?
What are you encrypting the files with?
How are you decrypting the files?
What scripting language are you using?
Do you get any error messages?
What have you already tried to attempt to resolve your issue?

Dunnpy
Answered 08/04/2015 by: dunnpy
Red Belt

  • OS: Windows 7-64bit
    Decrypting files using : %SYS32%\cipher.exe /D /A /S:C:\
    And then scanning to see if there are any encrypted files using : "%SYS32%\cipher.exe"/U /N >"C:\Encrypted_Files-ONLY.log"
    and I do see some files are still encrypted because they are ready only files.
    As per cipher.exe....files cannot be decrypted when they are ready only file attributes.

    So my question is how to decrypt those read only files.

    or else is there any script to get all read only files from entire C:\ and then uncheck ready only files and then do decrypt and then set it back to read only.

    any help should be appreciated.
Please log in to comment
Answer this question or Comment on this question for clarity