(转)NSIS使用心得
生活随笔
收集整理的這篇文章主要介紹了
(转)NSIS使用心得
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
NSIS使用心得??
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文件會報錯。而且表面上看不出錯誤在哪里。
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
轉載于:https://www.cnblogs.com/bluewelkin/archive/2008/09/09/1287367.html
總結
以上是生活随笔為你收集整理的(转)NSIS使用心得的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 从Flash到Silverlight进阶
- 下一篇: Wdows server 2003 ip