用Windows压缩命令行[重复]

时间:2022-08-30 00:15:45

Possible Duplicate:
Can Windows' built-in ZIP compression be scripted?

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

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.

我正在尝试通过命令行为SSIS包压缩文件。我知道7-Zip是一个很好的开源工具,但我将部署的服务器也没有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.

我唯一的工具是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

2 个解决方案

#1


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

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

DotNetZip on CodePlex

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.

#2


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.

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

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

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

#1


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

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

DotNetZip on CodePlex

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.

#2


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.

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

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

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