freefish
一直以来,很喜欢这个小巧的安装程序制作系统。
最近用它制作了几个安装程序。感觉不错。
制作出的安装程序,体积、速度都比Wise Installer要好得多。
中文件2.0rc1下载:
http://www.onlinedown.net/soft/21520.htm
第一次用它,光看看它自带的Examples\\example1.nsi
就可以知道个大概了。
这里只讲一下,我在使用中的几点心得吧。欢迎大家来谈一下自己的使用心得。
1、中文安装界面
在NSI文件的前边加入这一句就OK了。
LoadLanguageFile "${NSISDIR}\\Contrib\\Language files\\SimpChinese.nlf"
2、使用变量
有些时候,源文件夹的文件夹名很长。
你可以直接把文件夹名作为一个字符串。赋值给一个变量。
在变量使用之前,必须声明。
比如我们在这里创建一个UninstPath变量,让他代表注册表中的一个键
var UninstPath
然后使用 strCpy $UninstPath
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MyTest"
3、文件夹。
你如果想复制某个文件夹下的全部文件的话。
在File后边加一个/r参数,就可以搞定。否则的话,它不会复制源文件夹下的子文件
夹。
删除文件夹时,也是这样rmdir /r 删除文件夹及文件夹下边的全部文件、子文件夹。
4、反安装程序:
再建一个新的section
加入WriteUninstaller "$INSTDIR\\uninst.exe"即可。其中uninst.exe是反安装程序
的名字。
而且如果写入反安装程序的话。
NSI文件必须再包含一个名字为Uninstall的Section。这个Section中应当指明反安装
应该执行哪些操作。
比如
Section "Uninstall"
rmdir /r $INSTDIR ;/r是全部删除,包含子文件夹夹
SectionEnd
5、让反安装信息出现在添加/删除程序中。
NSIS自身不直接有让反安装信息出现在(控制面板-添加/删除程序)的函数。
所以需要手动将安装信息写入注册表。
var UninstPath ;声明一个变量保存注册表键的位置
Section "Write Uninstall Information"
strCpy $UninstPath
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MyProgram" ;此处
MyProgram可以自己定义
WriteRegStr HKLM $UninstPath "UninstallString" "$INSTDIR\\uninstall.exe"
;卸载程序位置
WriteRegStr HKLM $UninstPath "DisplayName" "我的反安装测试"
;卸载程序标题
WriteRegStr HKLM $UninstPath "DisplayVersion" "0.9.0.1"
;程序版本
WriteRegStr HKLM $UninstPath "HelpLink" "http://forum.3382.net"
;帮助链接
WriteRegStr HKLM $UninstPath "HelpTelephone" "13500000000"
;帮助电话
WriteRegStr HKLM $UninstPath "InstallLocation" "c:\\temp" ;
安装位置
WriteRegStr HKLM $UninstPath "InstallSource" "c:\\temp" ;
安装源位置
WriteRegStr HKLM $UninstPath "ModifyPath" "c:\\temp" ;
修改位置
WriteRegStr HKLM $UninstPath "ProductID" "000"
;产品的ID
WriteRegStr HKLM $UninstPath "Publisher" "CoC" ;产品出版商
WriteRegStr HKLM $UninstPath "RegCompany" "CoC" ;注册公司
WriteRegStr HKLM $UninstPath "RegOwner" "freef!sh"
;注册用户名
WriteRegStr HKLM $UninstPath "URLInfoAbout" "http://forum.3382.net"
;信息地址
WriteRegStr HKLM $UninstPath "URLUpdateInfo" "http://forum.3382.net"
;升级信息地址
WriteRegDWORD HKLM $UninstPath "VersionMajor" 0 ;dword:00000007
;版本
WriteRegDWORD HKLM $UninstPath "VersionMinor" 0 ;Dword:00000000
;版本
WriteRegStr HKLM $UninstPath "DisplayIcon" "" ;
;显示图标
SectionEnd
6、创建开始菜单快捷方式。
要先在开始菜单下创建一个文件夹,然后使用CreateSHortCut的函数。
Section "Create StartMenu Shortcut";
CreateDirectory "$SMPROGRAMS\\$STARTMENU_FOLDER\\MyProgram"
CreateShortCut "$SMPROGRAMS\\$STARTMENU_FOLDER\\MyProgram" "$INSTDIR\\register.exe"
SectionEnd ;
7、其它:
就是在Script文件中尽量避免输入全角的空格。这样script文件会报错。而且表面上看不出错误在哪里。
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=825866