Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Zip/Unzip using native ZipFolder Feature in XP


  • Please log in to reply
33 replies to this topic
Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
It provides a basic zip/unzip support in XP using the native ZipFolder support.
Naturally, the ZipFolder should be enabled for the script to work (regsvr32.exe /s zipfldr.dll).

The example in the script does:
zipping this script/CoHelper.ahk/FileHelper.ahk to script.zip in the temporary folder, then unzipping it in the temporary folder.

DOWNLOAD ZipFolder.ahk and CoHelper.ahk and FileHelper.ahk.

shajul
  • Members
  • 571 posts
  • Last active: Aug 01 2015 03:45 PM
  • Joined: 15 Sep 2006
great work..
exactly what i was looking for..

but unzip does not seem to work! am i missing something?
If i've seen further it is by standing on the shoulders of giants

my site | ~shajul | WYSIWYG BBCode Editor

freakkk
  • Members
  • 182 posts
  • Last active: Dec 16 2014 06:23 PM
  • Joined: 29 Jul 2005

am i missing something?

Yes. :D
Works fine here. What code are you using?

shajul
  • Members
  • 571 posts
  • Last active: Aug 01 2015 03:45 PM
  • Joined: 15 Sep 2006
Thanks for your prompt reply!

Works fine now! some bug in my system maybe :(

thanks again!
If i've seen further it is by standing on the shoulders of giants

my site | ~shajul | WYSIWYG BBCode Editor

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
Wow!

:D 8)

but, how the ... did I miss this excellent script? :shock:

Wed Jun 06, 2007



Drugwash
  • Guests
  • Last active:
  • Joined: --
Hello!

Apologies for barging in. I'm trying to find a simple, preferrably open-source solution to unpack a zip from within an ahk script - eventually a compiled script, more of an installer, that could be freely distributed.

Problem is, I need this to work in all Windows versions from Win95 to Vista, so relying on XP's built-in code is not an option. Could anyone kindly offer some tips in this regard? Thank you!

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: May 02 2019 09:16 PM
  • Joined: 21 Dec 2007
perfect
Never lose.
WIN or LEARN.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Very useful, many thanks.

stevenA
  • Guests
  • Last active:
  • Joined: --
Hi, is there anyway possible to have Password protection for the zip, for this process? :)

..:: Free Radical ::..
  • Members
  • 74 posts
  • Last active: May 30 2015 12:13 PM
  • Joined: 20 Sep 2006
Noticed since most of us have moved to COM stdlib, it may help someone looking for an updated version

Zip(sDir, sZip)
{
	If Not FileExist(sZip)
	{
		VarSetCapacity(Header, 22, 0)
		Header := "PK" . Chr(5) . Chr(6)
		ReadMemory(sZip, &Header, 22)
	}
	psh  := COM_ActiveXObject("Shell.Application")
	pzip := COM_Invoke(psh, "Namespace", sZip)
	COM_Invoke(pzip, "CopyHere", sDir, 4|16)
	Sleep,	1000
	COM_Release(pzip)
	COM_Release(psh)
}

Unz(sZip, sUnz)
{
	psh  := COM_ActiveXObject("Shell.Application")
	pzip := COM_Invoke(psh, "Namespace", sZip)
	punz := COM_Invoke(psh, "Namespace", sUnz)
	pitms:= COM_Invoke(pzip, "Items")
	COM_Invoke(punz, "CopyHere", "+" . pitms, 4|16)
	Sleep,	1000
	COM_Release(pitms)
	COM_Release(pzip)
	COM_Release(punz)
	COM_Release(psh)
}


aparden
  • Members
  • 15 posts
  • Last active: Feb 17 2010 12:54 AM
  • Joined: 12 Dec 2009

Wow!

:D 8)

but, how the ... did I miss this excellent script? :shock:

Wed Jun 06, 2007


Likewise!

Thx sean and free radical

Dreck
  • Guests
  • Last active:
  • Joined: --
Mhh, your version, sadly, doesn't work, Free Radical. :(

[quote]Function Name: "Namespace"
Error: The COM Object may not be a valid one![/quote]

Get the same error with "CopyHere".[/quote]

WankaUSR
  • Members
  • 87 posts
  • Last active: Jul 14 2013 09:59 AM
  • Joined: 14 Aug 2007
I had the same problem and the reason was that path you want to extract in must exist, zip file must exist and be careful how you parse variable to the function. if you are having problems please post your script

..:: Free Radical ::..
  • Members
  • 74 posts
  • Last active: May 30 2015 12:13 PM
  • Joined: 20 Sep 2006

Mhh, your version, sadly, doesn't work, Free Radical. :(

Function Name: "Namespace"
Error: The COM Object may not be a valid one!


Get the same error with "CopyHere".


works for me :cry:

Still needs FileHelper.ahk.
Don't forget to #include it.

Also, the sDir must exist, so just use FileSelectFolder to create the folder to zip to, before calling the function,
or add it to the function.

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
Full credit for re-writing these functions for AutoHotkey_L and COM_L goes to answer4u, I removed the Sleep commands as I believe they were related to the timing of the manual release of COM objects in the original, which is no longer necessary in COM_L:

Zip(sDir, sZip)
{
   If Not FileExist(sZip)
   {
      VarSetCapacity(Header, 22, 0)
      Header := "PK" . Chr(5) . Chr(6)
      ReadMemory(sZip, &Header, 22)
   }
  COM_CreateObject( "Shell.Application" ).Namespace( sZip ).CopyHere( sDir, 4|16 )

}

Unz(sZip, sUnz)
{
   psh  := COM_CreateObject("Shell.Application")
   psh.Namespace( sUnz ).CopyHere( psh.Namespace( sZip ).items, 4|16 )

}