Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unzip Password-protected files

I am trying to extract files from a password-protected zip, in a USB drive, using PowerShell. I have looked up many ways but the easiest one doesn't seem to work.

$7ZipPath = "C:\Program Files\7-Zip\7z.exe"
$zipFile = "E:\passwordprotectedtest.zip"
$zipFilePassword = "Foo"

& $7ZipPath e -oE:\ -y -tzip -p "$zipFilePassword" "$zipFile"

I keep getting this error:

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Error
Cannot use absolute pathnames for this command

I then moved to the file to my desktop, changed $zipFile = "passwordprotectedtest.zip", changed -oE:\ to -oC:\.

That fixed the pathname error but started getting this error instead

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Error
Cannot find archive
like image 222
Harry Singh Avatar asked Aug 24 '15 19:08

Harry Singh


1 Answers

Try this way:

$7ZipPath = '"C:\Program Files\7-Zip\7z.exe"'
$zipFile = '"e:\passwordprotectedtest.zip"'
$zipFilePassword = "Foo"
$command = "& $7ZipPath e -oe:\ -y -tzip -p$zipFilePassword $zipFile"
iex $command
like image 74
Dmitry VS Avatar answered Oct 23 '22 11:10

Dmitry VS