我的第一个打包安装程序,以下是脚本代码:
; 该脚本使用 HM VNISEdit 脚本编辑器向导产生
; 安装程序初始定义常量
!define PRODUCT_NAME "安钢计质量三级信息系统"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "RVSOFT, Inc."
!define PRODUCT_WEB_SITE "http://www.rv.com.cn"
!define PRODUCT_DIR_REGKEY "Software"Microsoft"Windows"CurrentVersion"App Paths"RV.AQQIS.SystemFrame.exe"
!define PRODUCT_UNINST_KEY "Software"Microsoft"Windows"CurrentVersion"Uninstall"${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
SetCompressor lzma
; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
!include "MUI.nsh"
; MUI 预定义常量
!define MUI_ABORTWARNING ;'取消安装'确认窗口,
; MUI Settings / Icons
!define MUI_ICON "${NSISDIR}"Contrib"Graphics"Icons"orange-install-nsis.ico"
!define MUI_UNICON "${NSISDIR}"Contrib"Graphics"Icons"orange-uninstall-nsis.ico"
; MUI Settings / Header
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}"Contrib"Graphics"Header"orange-r-nsis.bmp"
!define MUI_HEADERIMAGE_UNBITMAP "${NSISDIR}"Contrib"Graphics"Header"orange-uninstall-r-nsis.bmp"
; MUI Settings / Wizard
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}"Contrib"Graphics"Wizard"orange-nsis.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSISDIR}"Contrib"Graphics"Wizard"orange-uninstall-nsis.bmp"
; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
; 许可协议页面
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "..".."RVSoft"Application Sources"安装协议.txt"
; 安装目录选择页面
!insertmacro MUI_PAGE_DIRECTORY
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!define MUI_FINISHPAGE_RUN "$INSTDIR"RV.AQQIS.AutoUpdater.exe"
!insertmacro MUI_PAGE_FINISH
; 安装卸载过程页面
!insertmacro MUI_UNPAGE_INSTFILES
; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "SimpChinese"
; 安装预释放文件
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI 现代界面定义结束 ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "RV.AQQIS.ZL.EXE"
InstallDir "$PROGRAMFILES"安钢计质量三级信息系统"RV.AQQIS.ZL""
InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
ShowInstDetails show
ShowUnInstDetails show
BrandingText "http://www.rv.com.cn"
Section "RV.AQQIS.ZL" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "..".."VS2005Prj"AG-FrameWork"RV.AQQIS.AGLIMS"RV.AQQIS.AGLIMS"RV.AQQIS.AGLIMS"bin"wait.gif"
CreateDirectory "$SMPROGRAMS"安钢计质量三级信息系统"
CreateShortCut "$SMPROGRAMS"安钢计质量三级信息系统"安钢计质量三级信息系统.lnk" "$INSTDIR"RV.AQQIS.AutoUpdater.exe"
CreateShortCut "$DESKTOP"安钢计质量三级信息系统.lnk" "$INSTDIR"RV.AQQIS.AutoUpdater.exe"
File "..".."VS2005Prj"AG-FrameWork"RV.AQQIS.AGLIMS"RV.AQQIS.AGLIMS"RV.AQQIS.AGLIMS"bin"UpdateList.xml"
/*文件省略*/
File "..".."VS2005Prj"AG-FrameWork"RV.AQQIS.AGLIMS"RV.AQQIS.AGLIMS"RV.AQQIS.AGLIMS"bin"AGSurfaceINS.dll"
SectionEnd
Section -AdditionalIcons
WriteIniStr "$INSTDIR"${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS"安钢计质量三级信息系统"Website.lnk" "$INSTDIR"${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS"安钢计质量三级信息系统"Uninstall.lnk" "$INSTDIR"uninst.exe"
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR"uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR"RV.AQQIS.SystemFrame.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR"uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR"RV.AQQIS.SystemFrame.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
/******************************
* 以下是安装程序的卸载部分 *
******************************/
Section Uninstall
Delete "$INSTDIR"${PRODUCT_NAME}.url"
/*文件省略*/
Delete "$INSTDIR"wait.gif"
Delete "$SMPROGRAMS"安钢计质量三级信息系统"Uninstall.lnk"
Delete "$SMPROGRAMS"安钢计质量三级信息系统"Website.lnk"
Delete "$DESKTOP"安钢计质量三级信息系统.lnk"
Delete "$SMPROGRAMS"安钢计质量三级信息系统"安钢计质量三级信息系统.lnk"
RMDir "$SMPROGRAMS"安钢计质量三级信息系统"
RMDir "$INSTDIR"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
#-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "您确实要完全移除 $(^Name) ,及其所有的组件?" IDYES +2
Abort
FunctionEnd
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从您的计算机移除。"
FunctionEnd