views:

582

answers:

4

I'm trying to Zip a file through the command line for an SSIS package. I know 7-Zip is a great open source tool to use, but the server I will be deploying too does not have 7-Zip.

The only tools I have are the Windows Compress.exe and Compact.exe. However when trying this it seems to create invalid/corrupt zip files.

This is what I have tried:
Compress -z c:\test.xls c:\test.zip
Compress -zx c:\test.xls c:\test.zip
Compress c:\test.xls c:\test.zip
+3  A: 

see the answer on Stack Overflow :)

jmihalicza
A: 

Thanks but I'm still wondering why the command line arguments don't work even just by running it in a command window. From what I've found some say Compress.exe doesn't work in NTFS, which I think would be odd. I'm not sure though.

The vb code in the link you might work, but it would be easier/better for me to do a Execute process task than a Script task in SSIS.

MaxGeek
+1  A: 

As far as I know compress.exe is not the widely used (PK-)Zip format, but a MS specific compression used in setups and cab files.

The extension of files compressed with it used to be ._??, program._xe for example.

jmihalicza
+2  A: 

DotNetZip includes command-line tools that you can include in a script. it works with NTFS ;) It's free, open source.

DotNetZip on CodePlex

c:\temp> zipit -?
Zipit.exe:  zip up a directory, file, or a set of them, into a zipfile.
            Depends on Ionic's DotNetZip library. This is version 1.8.2.13 of the utility.
usage:
   ZipIt.exe <ZipFileToCreate> [arguments]

arguments:
  -utf8                 - use UTF-8 encoding for entries with comments or
                          filenames that cannot be encoded with the default IBM437
                          code page.
  -aes                  - use WinZip-compatible AES 256-bit encryption for entries
                          subsequently added to the archive. Requires a password.
  -sfx [w|c]            - create a self-extracting archive, either a Windows or console app.
  -64                   - use ZIP64 extensions, for large files or large numbers of files.
  -cp <codepage>        - use the specified numeric codepage for entries with comments
                          or filenames that cannot be encoded with the default IBM437
                          code page.
  -p <password>         - apply the specified password for all succeeding files added.
                          use "" to reset the password to nil.
  -c <comment>          - use the given comment for the next file added to the archive.
  -zc <comment>         - use the given comment for the archive.
  -d <path>             - use the given directory path in the archive for
                          succeeding items added to the archive.
  -s <entry> 'string'   - insert an entry of the given name into the
                          archive, with the given string as its content.
  -flat                 - store the files in a flat dir structure; do not use the
                          directory paths from the source files.
  <directory> | <file>  - add the directory or file to the archive.
Cheeso