1

可能重复:
可以编写 Windows 的内置 ZIP 压缩脚本吗?

我正在尝试通过命令行为 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
4

2 回答 2

3

DotNetZip 包含可以包含在脚本中的命令行工具。它适用于 NTFS ;) 它是免费的、开源的。

CodePlex 上的 DotNetZip

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.
于 2009-02-10T06:28:06.543 回答
1

据我所知,compress.exe 不是广泛使用的 (PK-)Zip 格式,而是用于设置和 cab 文件的 MS 特定压缩。

用它压缩的文件的扩展名曾经是._??,例如program._xe。

于 2009-01-28T01:33:55.407 回答