Unzip Password-protected files

强颜欢笑 提交于 2021-02-09 00:44:47

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/32189955/unzip-password-protected-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!