Win7 Zip Compression in BAT

June 9, 2010 at 20:01:58
Specs: Windows 7, AMD Athlon x2/4GB
My question has to do with accessing Windows 7 based ZIP compression via BAT file. I currently use a 7Zip command line system to do my compressing/decompressing which works fine. However, since Windows has its own ZIP compressing...I wanted to see if anyone knew exactly how to access that.

From what I checked online its a difficult thing to do and most forums recommend external party compression devices (like I do with 7Zip). The point here of course is not practicality but the mental challenge of figuring out that Windows 7 zip feature.

I am not interested in other party appz like winzip, pkzip...blah blah blah, this is about Windows 7 zip and the challenge herein mentioned.

Your views?

See More: Win7 Zip Compression in BAT

Report •

June 22, 2010 at 11:02:41
This topic's old, but I was gone, and now I'm back. So whatever.

The zip file handling is handled by the Windows shell, so you can use the Shell.Application COM object to zip/unzip files. It's kind of touchy, but it'll get the job done. Usually.

Every Windows native scripting language can use COM objects, with the exception of batch.

VBScript example:

Const zipPath = "C:\"
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell32 = CreateObject("Shell.Application")
docs = CreateObject("WScript.Shell").SpecialFolders("MyDocuments")

'Create blank zip file
With fso.OpenTextFile(zipPath, 2, True)
  .Write "PK" & Chr(5) & Chr(6) & String(18, Chr(0))
End With
Set zip = shell32.NameSpace(zipPath)

'Put stuff into zip file
zip.CopyHere shell32.NameSpace(docs)

'Sleep long enough to let zipping start
WScript.Sleep 10000

Report •

June 22, 2010 at 12:06:39
Great info thank you.

Report •

Related Solutions

Ask Question