最近由于工作需要,研究了下Winrar制作自解压exe的方法。简单介绍一下:
举例:rar a -r -sfx -z<file> xxx.exe *.*
其中 -z<fiel>表明从注释文件里面提取注释,以便解压后自动运行(调用exe等);xxx.exe表明压缩后的exe文件名。通配符*.*与-r参数配合表示带子目录压缩当前目录下的所有文件。当然,也可以指定其它路径,把路径带上即可。
想要自解压后调用某个exe,注释是十分重要的。这里列举一下SFX的参数:
1、Delete=[filename] 解压后删除某个文件。
Examples:
Delete=rarlng.dll
2、License=[title of the license dialog] 显示版权对话框
{
license text1
license text2
…
}
Examples:
License=End user license agreement
{
All copyrights to RAR are exclusively owned by the author.
This program is shareware. Anyone may use this software during a test period.
Following this test period, you MUST register.
}
3、Path=[your path here] 表明你要解压的目录。
4、Presetup=[program] 解压前要调用的exe。
5、SavePath 保存路径,通常和path一起使用。
Examples:
Path=Calc 3.05
SavePath
6、TempMode=[Question][,Title] 表明将要先解压到一个临时文件夹,并且弹出一个对话框。
Examples:
TempMode
Unpacks to temp folder.
TempMode=Do you wish to continue installation of Calculator 3.05?, Calculator setup
Creates temp folder, and displays dialog with text "Do you wish to continue installation of Calculator 3.05?"
7、Setup=[program] 表明解压后需要调用某个exe。
Examples:
Setup=setup.exe
8、Silent=X 静默模式选择,完全静默选1。
where X can be:
1=Start dialog is completely hidden, including the progress bar and file names.
2=Confirmation to start extracting is skipped, but users still see performing of the archive unpacking.
9、Overwrite=X 解压时是否覆盖已有文件。
where X can be:
0=User will be asked before overwriting files
1=Overwrite the file if it exists without confirmation
2=All existing files will not be overwritten
10、Shortcut=X, "PATHTOPROGRAM", "SUBMENU", "DESCRIPTION", "SHORTCUTNAME" 解压后建立一个快捷方式。
where X can be:
D=Desktop
S=Start Menu
P=Start Menu/Programs
T=Startup
Examples:
Shortcut=P, "mplayerc.exe", "Media Player", "Media Player Classic v6.4.8.2", "Media Player Classic"
11、Title=[title] 指定安装对话框的Title。
选择了合适的参数,把其存为一个a.txt文件,在-z参数后指定此文件,自解压后就可以自动执行SFX指定的操作了。
需要确定的一点是,使用Setup=[program]参数时,一定要明确知道解压后exe的位置,否则你将会收到一个对话框:请转到“控制面板”来安装和配置系统组件。。。