Reputation:
i want to extract an archive called test.rar with 7zip but nothing worked for me
Archive: test.rar
Password(with quote):"."
I tried
& "C:\Program Files (x86)\7-Zip\7z.exe" t -p'"".""' test.rar
& "C:\Program Files (x86)\7-Zip\7z.exe" t -p""."" test.rar
& "C:\Program Files (x86)\7-Zip\7z.exe" t "-p"."" test.rar
& "C:\Program Files (x86)\7-Zip\7z.exe" t -p'"."' test.rar
& "C:\Program Files (x86)\7-Zip\7z.exe" t -'p"."' test.rar
& "C:\Program Files (x86)\7-Zip\7z.exe" t -p'"".""' test.rar
Upvotes: 2
Views: 443
Reputation: 437408
Up to at least PowerShell 7.1, passing arguments with embedded "
characters to external programs such as 7z.exe
is fundamentally broken, unfortunately.
While there are workarounds, the simpler solution is to provide the password via stdin.
The post that Mark Tolonen links to shows this technique for cmd.exe
, via <
, its input-redirection operator, which PowerShell does not support, however.
Instead, use PowerShell's pipeline to supply data that an external program receives via stdin.
Assuming that the verbatim password is "."
:
'"."' | & "C:\Program Files (x86)\7-Zip\7z.exe" t test.rar
Upvotes: 2