# Native unzip on Windows

**URL:** <https://forum.xojo.com/t/native-unzip-on-windows/20864>\
**Category:** Windows\
**Created:** [December 11, 2014, 4:10pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864 "2014-12-11T16:10:20Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 11, 2014, 7:57pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/21 "2014-12-11T19:57:40Z")

</div>

I see. At this phase I’m not worried about security/permission issues, i.e., I’m assuming the user has the privileges to replace their app. But since that doesn’t mean they will have the privileges to access all system services, it looks like an external app is required. Pity.

Who ships an OS without the proper zip tools installed natively?!?

Thanks to all for your input and help.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [December 11, 2014, 8:00pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/22 "2014-12-11T20:00:52Z")

</div>

[https://social.technet.microsoft.com/Forums/systemcenter/en-US/6f8129d0-3cbd-4e59-9d3b-a6376b9ff3cf/cscript-vbs-deployment-fails-due-to-permission-issue](https://social.technet.microsoft.com/Forums/systemcenter/en-US/6f8129d0-3cbd-4e59-9d3b-a6376b9ff3cf/cscript-vbs-deployment-fails-due-to-permission-issue)

[http://support.microsoft.com/KB/248121](http://support.microsoft.com/KB/248121)

// Windows systems have mixed support app files, different versions, missing features. etc.

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 11, 2014, 8:13pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/23 "2014-12-11T20:13:42Z")

</div>

[quote=151090:@Kem Tekinay]I see. At this phase I’m not worried about security/permission issues, i.e., I’m assuming the user has the privileges to replace their app. But since that doesn’t mean they will have the privileges to access all system services, it looks like an external app is required. Pity.

Who ships an OS without the proper zip tools installed natively?!?

Thanks to all for your input and help.[/quote]

Why not simply use an installer to replace the current app ?

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 11, 2014, 8:28pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/24 "2014-12-11T20:28:38Z")

</div>

For my purposes, that would be more work and less than ideal. The app this will be used in initially are drag and drop, no installer required.

---

<div class="post-metadata">

**Author:** ![Tanner\_Lee1](https://forum.xojo.com/letter_avatar_proxy/v4/letter/t/ba8739/32.png) [@Tanner\_Lee1](https://forum.xojo.com/u/Tanner_Lee1)\
**Post date:** [December 11, 2014, 9:48pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/25 "2014-12-11T21:48:58Z")

</div>

> [@150960:@Michel Bujardet](#):
>
> How was the file created ? Zip is not quite homogenous. Some zipping apps use strange compression formats that are not necessarily compatible with the default system utilities.

Dunno, it was a zip of a Windows port of Midnight Commander.

Looks like others have had success with `expand`. But if it failed in my test, how reliable would it be in an xplat situation?

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 11, 2014, 9:57pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/26 "2014-12-11T21:57:25Z")

</div>

[quote=151148:@Tanner Lee]Dunno, it was a zip of a Windows port of Midnight Commander.

Looks like others have had success with `expand`. But if it failed in my test, how reliable would it be in an xplat situation?[/quote]

I sell tens of thousands of zip archives prepared on Mac with the OS X right click compress to Windows users every year. None of them ever complained it did not expand correctly. I think that is a pretty good level of compatibility.

On Windows, utilities such as Winzip can provide a legacy compression, which works fine with both Expand and Mac, but the “extra” compression is not compatible. I hate that kind of thing, and suspect that what you encountered. Most every zip utility on Windows has these pesky proprietary zip formats.

I would tend to stay away from anything that is not built in. But that’s just me.

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 11, 2014, 10:19pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/27 "2014-12-11T22:19:34Z")

</div>

Looks like that’s not an option in my case. Unfortunate that it will add 3.7 MB to the project, but I guess that’s not that big a deal in today’s high-speed world. I’m more distressed that it adds another step for Windows-targeting developers.

---

<div class="post-metadata">

**Author:** ![Bob\_Coleman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/a88e57/32.png) [@Bob\_Coleman](https://forum.xojo.com/u/Bob_Coleman)\
**Post date:** [December 11, 2014, 10:22pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/28 "2014-12-11T22:22:37Z")

</div>

If a person prepares their update with Compress it will always work with Expand.

Any reason not to use .cab files for the updates in Windows?

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 11, 2014, 10:26pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/29 "2014-12-11T22:26:59Z")

</div>

Yes. I work on a Mac. 🙂

Eventually I’ll expand to allow handling of various file types from cab to pkg to installer files. But that’s not what I need right now.

---

<div class="post-metadata">

**Author:** ![Bill\_Gookin](https://forum.xojo.com/user_avatar/forum.xojo.com/bill_gookin/32/172_2.png) [@Bill\_Gookin](https://forum.xojo.com/u/Bill_Gookin)\
**Post date:** [December 11, 2014, 10:59pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/30 "2014-12-11T22:59:10Z")

</div>

[quote=151163:@Kem Tekinay]Yes. I work on a Mac. 🙂

Eventually I’ll expand to allow handling of various file types from cab to pkg to installer files. But that’s not what I need right now.[/quote]  
Forget what you need, Kem, think about what WE need right now. 🙂

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 11, 2014, 10:59pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/31 "2014-12-11T22:59:28Z")

</div>

Synchronicity is an amazing thing.  
See [https://forum.xojo.com/18150-howto-pack-unpack-files-with-use-of-xstandard-free-activex-tar-/0#p151133](https://forum.xojo.com/18150-howto-pack-unpack-files-with-use-of-xstandard-free-activex-tar-/0#p151133)

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 11, 2014, 11:10pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/32 "2014-12-11T23:10:34Z")

</div>

gzip is different than zip, or did I miss something with that dll?

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 12, 2014, 12:05am UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/33 "2014-12-12T00:05:22Z")

</div>

> [@151183:@Kem Tekinay](#):
>
> gzip is different than zip, or did I miss something with that dll?

I did not pretend to give you a solution. Just to note that similar concerns appeared in two threads synchronously.

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 12, 2014, 12:10am UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/34 "2014-12-12T00:10:01Z")

</div>

Understood.

---

<div class="post-metadata">

**Author:** ![Eugene\_Dakin](https://forum.xojo.com/user_avatar/forum.xojo.com/eugene_dakin/32/25738_2.png) [@Eugene\_Dakin](https://forum.xojo.com/u/Eugene_Dakin)\
**Post date:** [December 12, 2014, 5:36am UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/35 "2014-12-12T05:36:05Z")

</div>

Hi Kem,

Here are some interesting articles, although I have not created a native unzip program for Windows … yet 🙂

This would need converting from Visual Basic 6 to Xojo: [VB6 Declare Unzip Class](https://github.com/wqweto/UnzipClass/blob/master/Src/cZip.cls)

Another way is to unzip through COM. Instructions are here: [Unzip by COM](http://www.howtogeek.com/tips/how-to-extract-zip-files-using-powershell/)

Does this help or is thing on the wrong path?

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 12, 2014, 5:42am UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/36 "2014-12-12T05:42:45Z")

</div>

Thanks Eugene. I decided to go the path of including an extra utility. Right now it’s 7z, but maybe something else later. For now, I have that part working.

---

<div class="post-metadata">

**Author:** ![scott\_boss](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@scott\_boss](https://forum.xojo.com/u/scott_boss)\
**Post date:** [December 12, 2014, 6:54am UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/37 "2014-12-12T06:54:02Z")

</div>

[quote=151090:@Kem Tekinay]Who ships an OS without the proper zip tools installed natively?!?  
[/quote]

many for many years… they want you to purchase a tool.

---

<div class="post-metadata">

**Author:** ![John\_Hansen](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@John\_Hansen](https://forum.xojo.com/u/John_Hansen)\
**Post date:** [December 12, 2014, 9:11am UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/38 "2014-12-12T09:11:24Z")

</div>

> [@151183:@Kem Tekinay](#):
>
> gzip is different than zip, or did I miss something with that dll?

Not sure if have have read the link ([https://forum.xojo.com/18150-howto-pack-unpack-files-with-use-of-xstandard-free-activex-tar-/0#p151133](https://forum.xojo.com/18150-howto-pack-unpack-files-with-use-of-xstandard-free-activex-tar-/0#p151133)) But Xstandard provide also an ActiveX DLL for Zip. But this you will need to provide your email address for download it. ([http://www.xstandard.com/en/documentation/xzip](http://www.xstandard.com/en/documentation/xzip) and the code to use it, is the same as for gzip and tar as shown in the above link.

What I understood it’s free for use in commercial applications as well.

---

<div class="post-metadata">

**Author:** ![John\_Hansen](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@John\_Hansen](https://forum.xojo.com/u/John_Hansen)\
**Post date:** [December 12, 2014, 10:34am UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/39 "2014-12-12T10:34:43Z")

</div>

[quote=150871:@Kem Tekinay]I want unzip files from my app. On the Mac/Linux size, I can count on the proper tools being available through the shell, but not in Windows, and I don’t want to install anything additional on the user’s system.

I found [this](http://stackoverflow.com/questions/21704041/creating-batch-script-to-unzip-a-file-without-additional-zip-tools) which uses (I think) a VBScript to do the job. Before I go down the rabbit hole of testing, does anyone think this will _not_ work on XP or higher?

Is there a better way to do it that doesn’t involve distributing an external app or installing a third-party class or plugin?

(I know and use @Thomas Tempelmann 's excellent zip class, but can’t for this project.)[/quote]

I just had some time to figure this out. The problem is, there is a bug in Xojo so you can’t use Shell.NameSpace in Xojo.

Here is the code that will work for windows:

```auto
  Dim ZipFile, ExtractTo As String
  Dim fso, objShell, FilesInZip, MyFolder1, MyFolder2 As OLEObject
  Dim ZipParams(1), ExtractParams(1) As variant
  
  
  ZipFile = "C:\\Temp\\test.zip"
  ExtractTo = "C:\\Temp\\Test"
  
  ZipParams(1) = ZipFile
  ExtractParams(1) = ExtractTo
  
  //If the extraction location does not exist create it
  fso = New OLEObject("Scripting.FileSystemObject")
  If NOT fso.FolderExists(ExtractTo) Then
    fso.CreateFolder(ExtractTo)
  End If
  
  
  
  objShell = New OLEObject("Shell.Application")
  MyFolder1 = objShell.Invoke("NameSpace", ZipParams)
  MyFolder2 = objShell.Invoke("NameSpace", ExtractParams)
  
  
  //More info see: http://msdn.microsoft.com/en-us/library/windows/desktop/bb787868%28v=vs.85%29.aspx
  //Extract the contants of the zip file.
  MyFolder2.CopyHere(MyFolder1.Items)
  
  
  fso = Nil
  objShell = Nil
  
exception err as oleexception
  msgbox err.message
```

---

<div class="post-metadata">

**Author:** ![Andre\_Kuiper](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@Andre\_Kuiper](https://forum.xojo.com/u/Andre_Kuiper)\
**Post date:** [December 12, 2014, 2:18pm UTC](https://forum.xojo.com/t/native-unzip-on-windows/20864/40 "2014-12-12T14:18:33Z")

</div>

@John Hansen  
That works fantastic!  
I have seen several examples from your hand and i wonder where you got all that knowledge, it’s realy amazing!

Thanks for sharing this!

[Previous page](https://forum.xojo.com/t/native-unzip-on-windows/20864.md?page=1)

[Next page](https://forum.xojo.com/t/native-unzip-on-windows/20864.md?page=3)
