2009-01-27 102 views
1

可能重複荏苒:
Can Windows' built-in ZIP compression be scripted?命令行與Windows

我試圖通過一個SSIS包的命令行來壓縮文件。我知道7-Zip是一個很好的開源工具,但我將部署的服務器也沒有7-Zip。

我唯一使用的工具是Windows Compress.exe和Compact.exe。 但是,當試圖這似乎創建無效/損壞的zip文件。

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 
+0

您正在使用什麼版本的SQL Server? – BuddyJoe 2009-01-27 22:11:38

+0

我正在使用SQL 2005 – MaxGeek 2009-01-27 23:10:41

回答

1

據我所知,compress.exe並不是廣泛使用的(PK-)Zip格式,而是用於設置和cab文件的MS專用壓縮。

用它壓縮過的文件的擴展名曾經是._ ??,例如program._xe。

3

DotNetZip包括可以包含在腳本中的命令行工具。 它適用於NTFS;)它是免費的,開源的。

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.