This project is read-only.

Creating a ZIP file using VB Script in 64-bit Windows 2008

Jul 18, 2009 at 3:24 AM
Edited Jul 18, 2009 at 3:27 AM

I ran the MSI file to install all the DotNetZip files.  When I executed this line:

Set zip = CreateObject("Ionic.Zip.ZipFile")

in my VB Script, I got this error:

ActiveX component can't create object 'Ionic.Zip.ZipFile'

Is DotNetZip compatiable with 64-bit Windows Server 2008?

Jul 18, 2009 at 4:46 AM

yes.  What version of .NET do you have installed?   Have you verified that the COM object is installed and registered properly?

can you use DotNetZip from a .NET program?

Jul 18, 2009 at 9:25 AM

.NET is 3.5 SP1.

The Ionic.Zip.dll is installed in D:\Program Files (x86)\Dino Chiesa\DotNetZip Runtime v1.8, but I don't know how to check if it is registered correctly.

I haven't tried a .NET program yet.

Jul 18, 2009 at 3:51 PM

If DotNetZip is registered, then in the registry you'll find a key under this name:  HKEY_CLASSES_ROOT\Ionic.Zip.ZipFile\CLSID .

The value should be {7621E9CE-6878-36C6-9E03-49CCA5E3291C}.


Jul 18, 2009 at 4:00 PM

The other thing you can try is using Powershell to create the zipfile.  Powershell is a newer scripting environment for Windows, the philosophical replacement for vbscript.  It's included on Windows Server 2008. It does not use COM. 

You can find examples here:

Jul 18, 2009 at 5:47 PM

It is registered, but the CLSID is {5312682D-2E00-3D2B-8C80-50AB392B0517}, which is different from yours.  Does it matter?

Jul 19, 2009 at 12:10 AM

no, it shouldn't matter.

Jul 19, 2009 at 1:33 AM

Here is what I know so far.  I have the following script executed and it failed with the error - Can't create object.  I used the Process Monitor to trace and found out HKCR\CLSID\{5312682D-2E00-3D2B-8C80-50AB392B0517} was being opened (RegOpenKey), but the result is "NAME NOT FOUND."  It means the DLL was registered and the VB Script could find it from the registry, but failed to locate the actual DLL.

Option Explicit
    dim zip
    Set zip = CreateObject("Ionic.Zip.ZipFile")

Could you suggest where I should look next?  Thank you.

Jul 19, 2009 at 3:21 PM

What I would suggest is to re-register the assembly then.

  1. open a cmd.exe prompt
  2. cd to the directory that holds the Ionic.Zip.dll file
  3. c:\windows\Microsoft.NET\Framework\v2.0.50727\regasm.exe  /codebase  Ionic.Zip.dll
  4. try running your script again


Jul 19, 2009 at 8:49 PM

It is working after registering the asssembly.  Thank you so much.

Now I have another problem.  If I call zip.AddFile fullFileName, it works.  But if I call zip.AddFile fullFileName, "", an error saying "Wrong number of arguments or invalid property assignment."  What did I do wrong?


Jul 19, 2009 at 11:31 PM

I don't know why it would not have been registered when you installed it.  ??  But I'm glad that part is working now.

On the next problem - with COM interop.  I don't know why that is happening. ?   I guess I hadn't tested that overload.  It looks to me like it should work.

As a workaround, You can rename the entry after you've added it.


Jul 19, 2009 at 11:39 PM

Sorry, I don't know how to rename the entry?  Could you give me some instructions?  Thank you.

Jul 20, 2009 at 1:28 AM
Edited Jul 20, 2009 at 7:12 PM


    Dim entry
    Set entry = zip1.AddFile ("c:\directory\FileToBeAdded.txt")
    ' remove the directory structure for the just-added entry
    entry.FileName = "FileToBeAdded.txt"

You could achieve the same effect by changing the current directory to be the one that contains the file to be zipped, before adding it.

Jul 20, 2009 at 6:38 PM

Sorry not to state clearly what I want to do.  I want to pass an empty string to AddFile as a second parameter so that the the folder structure won't be kept.  Changing the entry's name won't do that, will it?

Jul 20, 2009 at 7:10 PM
Edited Jul 20, 2009 at 7:13 PM

Yes, setting the FileName on the entry will implicitly set the directory structure for that entry.  If there is a directory in the filename, then it is used when saving that entry into the zip file.  If there is no directory - in other words there is no backslash (or forward slash), then the entry will be stored in the "top level" directory in the zip archive.

I also found out that with VBScript and COM clients, you will not be able to call the overloaded AddFile() method, the one that takes two strings.  This is not something I will be able to fix in the library.  It's a consequence of COM interop.

So, the best way to do what you want is to set the FileName on the entry after adding it to the archive.

ps: I edited the code above to be more clear about what you wanted to do.

Jul 20, 2009 at 9:00 PM

It is working great now.  Thank you for all your help.

Jul 20, 2009 at 10:59 PM

great, glad to hear it.