【发布时间】:2015-08-24 19:13:05
【问题描述】:
我正在尝试使用 PowerShell 从 USB 驱动器中受密码保护的 zip 中提取文件。我查找了很多方法,但最简单的方法似乎不起作用。
$7ZipPath = "C:\Program Files\7-Zip\7z.exe"
$zipFile = "E:\passwordprotectedtest.zip"
$zipFilePassword = "Foo"
& $7ZipPath e -oE:\ -y -tzip -p "$zipFilePassword" "$zipFile"
我不断收到此错误:
7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Error
Cannot use absolute pathnames for this command
然后我将文件移动到我的桌面,更改了$zipFile = "passwordprotectedtest.zip",更改了-oE:\ to -oC:\。
修复了路径名错误,但开始出现此错误
7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Error
Cannot find archive
【问题讨论】:
-
您是从 E:->C: 还是从 E:->Desktop 移动的?如果是后者,需要提供完整路径,7z.exe 不会知道你的桌面在 C:\
-
我将文件从 E:\ 移动到 C:\...\Desktop(与脚本相同的目录)。我还提供了我的桌面的完整路径,但出现了第一个错误。
-
尝试使用
Start-Process并使用-ArguementList-edit 列出参数,有关详细信息,请参阅here
标签: powershell password-protection 7zip