Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have directories with hundreds of RAR files. Currently I use Powershell 2.0 with a script that utilizes WinRAR's RAR utility to decompress the files. The issue is that a small number of the files end up being encrypted, which pauses the script and requires interaction. Is there any way to do one of the following:

  1. Identify the encrypted files before trying to decompress
  2. Entirely ignore the encrypted files
  3. Automate an incorrect (or correct) password that will attempt to open the file, but just skip it if incorrect.

NOTE: Some of the compressed files encrypt just file contents, whereas others encrypt file name and file contents.

Relevent Code:

$files = Get-ChildItem
foreach($file in $files)
    if($file.Attributes -eq "Archive")
        $folder = $file.basename
        rar x $file $folder\ -y
share|improve this question
Could you post the script? Or at least the portion that is where the pause happens? – EBGreen Jun 22 '11 at 19:18
up vote 3 down vote accepted

Try the -p- parameter:

-p-     Do not query password

Edit: Just tested -p-, and extraction fails with a CRC error in the encrypted file file.ext. Corrupt file or wrong password.

share|improve this answer
Does just what I wanted. Fails password attempt and continues the script. Thanks. – viking Jun 29 '11 at 20:55
@viking: Please click the blue "+50" button next to the answer to award the bounty. – Wuffers Jul 3 '11 at 18:22

It's been a long time since I've used RAR for anything. I do recall that it had an extensive list of command line switches to use though. The 'av-' switch should disable the authenticity verification check, not sure what kind of output that will generate though. So the rar command would be something like:

rar x $file $folder\ -y av-

I'd suggest giving it a try and see what happens.

share|improve this answer
Thanks, I'll give it a try. – viking Jun 27 '11 at 12:48
No luck. Same behavior as before. – viking Jun 29 '11 at 19:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .