1

I've seen a great post on this site about using a PowerShell script to use a batch file to unzip a file:

How can you zip or unzip from the script using ONLY Windows' built-in capabilities?

But I cant find anywhere about how to use PowerShell with a password protected zip file using only Windows native zip - no 7-zip or likewise since I can't install stuff on my work machine.

Since I could not find it in Google I'm a little worried it's not possible.

phuclv
  • 37,963
  • 15
  • 156
  • 475
labrys
  • 129
  • 1
  • 7
  • 1
    The problem as far as I can tell is that they didn't use a standard crypto algorithm so posting an answer with a power shell solution probably violates the patent. [ZIP Spec](https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE-6.3.4.TXT) see section 6.0 – Gregor y Dec 13 '18 at 03:17

2 Answers2

0

In Windows 7 and later it is not possible; the password capabilities were removed. I have heard (but never confirmed) that this was instigated by the EU anti-Microsoft actions, claiming that it was anticompetitive (against WinZip et alia).

Jeff Zeitlin
  • 9,773
  • 2
  • 21
  • 33
  • Where did you get that? The only built-in option for handling zip files prior to Windows 7 was the `Shell.Application` object, which to my knowledge never supported password-protected zip files. – Ansgar Wiechers Dec 19 '16 at 15:59
  • 2
    In Windows XP, the .ZIP handling capabilities included prompting for a password if the zip file was password protected - at least when you were doing it through the Windows Explorer. Presumably, the corresponding COM object had the capability, even if it might have been poorly documented or undocumented. – Jeff Zeitlin Dec 19 '16 at 16:15
  • 3
    I finally got around to researching this a bit more. As it turns out, nothing has been removed. Windows 7 and newer still prompt for an archive password. If (and only if) the old (and broken) ZipCrypto algorithm was used for encrypting the archive. In the meantime zip has learned AES encryption, though, but Microsoft never bothered adding support for this to `zipfldr.dll`. Trying to unpack an AES-encrypted archive as a "compressed folder" throws an error on Windows 7 as well as on Windows XP. The `Shell.Application` object never supported either ZipCrypto or AES encryption, though. – Ansgar Wiechers Jan 06 '17 at 17:20
  • I've used 7-Zip inside a powershell script to unzip files with password. 7-zip can be downloaded for free. – jdweng Nov 13 '22 at 10:18
-4

PowerShell 5 has Expand-Archive where you can give a password to decompress it.

Expand-Archive <zipfile> -Password (Read-Host -AsSecureString -Prompt Password)

AtomicFireball
  • 341
  • 2
  • 9