我们在Vista开始菜单中输入cmd回车,输入makecab e:\windows\notepad.exe d:\notepad.cab 。意思就是压缩e盘上windows vista自带的记事本程序,保存到磁盘分区d根目录中,如图1所示:

图1
我们可以看到Windows Vista记事本原始文件大小为 148 KB,如图2所示:

图2
在磁盘分区D上,我们可以看到压缩后的notepad.cab 文件大小为 112 KB,如图3所示:

图3
从结果看到我们只减少 148-112=36 KB,这是因为我们使用的是makecab默认的压缩算法。我们输入makecab /?查看它的参数如下
C:\Users\Vista地带>makecab /?
Cabinet Maker - Lossless Data Compression Tool
MAKECAB [/V[n]] [/D var=value ...] [/L dir] source [destination]
MAKECAB [/V[n]] [/D var=value ...] /F directive_file [...]
source File to compress.
destination File name to give compressed file. If omitted, the
last character of the source file name is replaced
with an underscore (_) and used as the destination.
/F directives A file with MakeCAB directives (may be repeated). Refer to
Microsoft Cabinet SDK for information on directive_file.
/D var=value Defines variable with specified value.
/L dir Location to place destination (default is current directory).
/V[n] Verbosity level (1..3).
这里我们可以使用compressiontype=lzx参数,采用LZX算法或 compressiontype=mszip 采用ZIP算法。
最后我们来说一下cab格式文件的解压缩,使用extract(点击下载)命令可以解压缩cab格式文件,这里我们输入extract d:\notepad.cab d:\notepad.exe 即可还原到exe原始文件,如图4所示:

图4