NSIS製作軟體安裝包
阿新 • • 發佈:2019-02-06
; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "XXSof"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "My company, Inc."
!define PRODUCT_WEB_SITE "http://www.KeeShow.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\XXSof.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
; MUI 1.67 compatible ------
!include "MUI.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "F:\XXSof.ico"
!define MUI_UNICON "F:\Uninstall.ico"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "XXSof\readme.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\XXSof.exe"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "SimpChinese"
; MUI end ------
RequestExecutionLevel admin
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "XXSofSetup.exe"
InstallDir "$PROGRAMFILES\XXSof"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Section "XXSof" SEC01
SetOutPath "$INSTDIR"
File "XXSof\config.xml"
File "XXSof\XXSof.exe"
File "XXSof\libcurl.dll"
File "XXSof\Model.dll"
File "XXSof\OpenAL32.dll"
File "XXSof\OpenThreads.dll"
SetOutPath "$INSTDIR\platforms"
File "XXSof\platforms\qminimal.dll"
File "XXSof\platforms\qoffscreen.dll"
File "XXSof\platforms\qwindows.dll"
SetOutPath "$INSTDIR\QtQuick\Dialogs"
File "XXSof\QtQuick\Dialogs\DefaultColorDialog.qml"
File "XXSof\QtQuick\Dialogs\DefaultDialogWrapper.qml"
File "XXSof\QtQuick\Dialogs\DefaultFileDialog.qml"
File "XXSof\QtQuick\Dialogs\DefaultFontDialog.qml"
File "XXSof\QtQuick\Dialogs\DefaultMessageDialog.qml"
File "XXSof\QtQuick\Dialogs\dialogplugin.dll"
SectionEnd
Section -AdditionalIcons
SetShellVarContext all
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\XXSof\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\XXSof\Uninstall.lnk" "$INSTDIR\uninst.exe"
CreateShortCut "$DESKTOP\XXSof.lnk" "$INSTDIR\XXSof.exe" "F:\XXSof.ico"
CreateDirectory "$SMPROGRAMS\XXSof"
CreateShortCut "$SMPROGRAMS\XXSof\XXSof.lnk" "$INSTDIR\XXSof.exe"
CreateShortCut "$SMPROGRAMS\XXSof\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\XXSof\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\XXSof.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\XXSof.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
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地從你的計算機移除。"
FunctionEnd
Function un.onInit
FindProcDLL::FindProc "${PRODUCT_NAME}.exe"
Pop $R0
IntCmp $R0 1 0 no_run
MessageBox MB_ICONSTOP "安裝程式檢測到 ${PRODUCT_NAME} 正在執行,請退出程式後重試"
Quit
no_run:
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你確實要完全移除 $(^Name) ,其及所有的元件?" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\Upgrade.exe"
Delete "$INSTDIR\Render.dll"
Delete "$INSTDIR\readme.txt"
Delete "$INSTDIR\qwindows.dll"
Delete "$INSTDIR\QtQuick.2\qtquick2plugin.dll"
Delete "$INSTDIR\imageformats\qjpeg.dll"
Delete "$INSTDIR\imageformats\qgif.dll"
Delete "$INSTDIR\icuuc52.dll"
Delete "$INSTDIR\icuin52.dll"
Delete "$INSTDIR\icudt52.dll"
Delete "$INSTDIR\glew32.dll"
Delete "$INSTDIR\FreeImage.dll"
Delete "$INSTDIR\Enginio.dll"
Delete "$INSTDIR\Core.dll"
Delete "$INSTDIR\config.xml"
SetShellVarContext all
Delete "$SMPROGRAMS\XXSof\Uninstall.lnk"
Delete "$SMPROGRAMS\XXSof\Website.lnk"
Delete "$DESKTOP\XXSof.lnk"
Delete "$SMPROGRAMS\XXSof\XXSof.lnk"
RMDir "$SMPROGRAMS\XXSof"
RMDir "$INSTDIR\QtQuick\XmlListModel"
RMDir "$INSTDIR\QtQuick\Window.2"
RMDir "$INSTDIR\QtQuick\PrivateWidgets"
RMDir "$INSTDIR\QtQuick\Particles.2"
RMDir "$INSTDIR\QtQuick\LocalStorage"
RMDir "$INSTDIR\QtQuick\Layouts"
RMDir "$INSTDIR\QtQuick\Dialogs\qml"
RMDir "$INSTDIR\QtQuick\Controls\Private"
RMDir "$INSTDIR\QtQuick\Controls"
RMDir "$INSTDIR\QtQuick.2"
RMDir "$INSTDIR\platforms"
RMDir "$INSTDIR\imageformats"
RMDir "$INSTDIR"
RMDIR /r /REBOOTOK "$INSTDIR"
RMDIR /r /REBOOTOK "$LOCALAPPDATA\XXSof"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
Var UNINSTALL_PROG
Var OLD_VER
Var OLD_PATH
Function .onInit
FindProcDLL::FindProc "${PRODUCT_NAME}.exe"
Pop $R0
IntCmp $R0 1 0 no_run
MessageBox MB_ICONSTOP "安裝程式檢測到 ${PRODUCT_NAME} 正在執行,請退出程式後重試"
Quit
no_run:
;FunctionEnd
;Function .onInit
ClearErrors
ReadRegStr $UNINSTALL_PROG ${PRODUCT_UNINST_ROOT_KEY} ${PRODUCT_UNINST_KEY} "UninstallString"
IfErrors done
ReadRegStr $OLD_VER ${PRODUCT_UNINST_ROOT_KEY} ${PRODUCT_UNINST_KEY} "DisplayVersion"
MessageBox MB_YESNOCANCEL|MB_ICONQUESTION \
"檢測到本機已經安裝了 ${PRODUCT_NAME} $OLD_VER。\
$\n$\n是否先解除安裝已安裝的版本?" \
/SD IDYES \
IDYES uninstall \
IDNO done
Abort
uninstall:
StrCpy $OLD_PATH $UNINSTALL_PROG -10
ExecWait '"$UNINSTALL_PROG" /S _?=$OLD_PATH' $0
DetailPrint "uninst.exe returned $0"
Delete "$UNINSTALL_PROG"
RMDir $OLD_PATH
done:
FunctionEnd
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "XXSof"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "My company, Inc."
!define PRODUCT_WEB_SITE "http://www.KeeShow.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\XXSof.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
; MUI 1.67 compatible ------
!include "MUI.nsh"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "F:\XXSof.ico"
!define MUI_UNICON "F:\Uninstall.ico"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "XXSof\readme.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\XXSof.exe"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "SimpChinese"
; MUI end ------
RequestExecutionLevel admin
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "XXSofSetup.exe"
InstallDir "$PROGRAMFILES\XXSof"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Section "XXSof" SEC01
SetOutPath "$INSTDIR"
File "XXSof\config.xml"
File "XXSof\XXSof.exe"
File "XXSof\libcurl.dll"
File "XXSof\Model.dll"
File "XXSof\OpenAL32.dll"
File "XXSof\OpenThreads.dll"
SetOutPath "$INSTDIR\platforms"
File "XXSof\platforms\qminimal.dll"
File "XXSof\platforms\qoffscreen.dll"
File "XXSof\platforms\qwindows.dll"
SetOutPath "$INSTDIR\QtQuick\Dialogs"
File "XXSof\QtQuick\Dialogs\DefaultColorDialog.qml"
File "XXSof\QtQuick\Dialogs\DefaultDialogWrapper.qml"
File "XXSof\QtQuick\Dialogs\DefaultFileDialog.qml"
File "XXSof\QtQuick\Dialogs\DefaultFontDialog.qml"
File "XXSof\QtQuick\Dialogs\DefaultMessageDialog.qml"
File "XXSof\QtQuick\Dialogs\dialogplugin.dll"
SectionEnd
Section -AdditionalIcons
SetShellVarContext all
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\XXSof\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\XXSof\Uninstall.lnk" "$INSTDIR\uninst.exe"
CreateShortCut "$DESKTOP\XXSof.lnk" "$INSTDIR\XXSof.exe" "F:\XXSof.ico"
CreateDirectory "$SMPROGRAMS\XXSof"
CreateShortCut "$SMPROGRAMS\XXSof\XXSof.lnk" "$INSTDIR\XXSof.exe"
CreateShortCut "$SMPROGRAMS\XXSof\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\XXSof\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\XXSof.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\XXSof.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
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地從你的計算機移除。"
FunctionEnd
Function un.onInit
FindProcDLL::FindProc "${PRODUCT_NAME}.exe"
Pop $R0
IntCmp $R0 1 0 no_run
MessageBox MB_ICONSTOP "安裝程式檢測到 ${PRODUCT_NAME} 正在執行,請退出程式後重試"
Quit
no_run:
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你確實要完全移除 $(^Name) ,其及所有的元件?" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\Upgrade.exe"
Delete "$INSTDIR\Render.dll"
Delete "$INSTDIR\readme.txt"
Delete "$INSTDIR\qwindows.dll"
Delete "$INSTDIR\QtQuick.2\qtquick2plugin.dll"
Delete "$INSTDIR\imageformats\qjpeg.dll"
Delete "$INSTDIR\imageformats\qgif.dll"
Delete "$INSTDIR\icuuc52.dll"
Delete "$INSTDIR\icuin52.dll"
Delete "$INSTDIR\icudt52.dll"
Delete "$INSTDIR\glew32.dll"
Delete "$INSTDIR\FreeImage.dll"
Delete "$INSTDIR\Enginio.dll"
Delete "$INSTDIR\Core.dll"
Delete "$INSTDIR\config.xml"
SetShellVarContext all
Delete "$SMPROGRAMS\XXSof\Uninstall.lnk"
Delete "$SMPROGRAMS\XXSof\Website.lnk"
Delete "$DESKTOP\XXSof.lnk"
Delete "$SMPROGRAMS\XXSof\XXSof.lnk"
RMDir "$SMPROGRAMS\XXSof"
RMDir "$INSTDIR\QtQuick\XmlListModel"
RMDir "$INSTDIR\QtQuick\Window.2"
RMDir "$INSTDIR\QtQuick\PrivateWidgets"
RMDir "$INSTDIR\QtQuick\Particles.2"
RMDir "$INSTDIR\QtQuick\LocalStorage"
RMDir "$INSTDIR\QtQuick\Layouts"
RMDir "$INSTDIR\QtQuick\Dialogs\qml"
RMDir "$INSTDIR\QtQuick\Controls\Private"
RMDir "$INSTDIR\QtQuick\Controls"
RMDir "$INSTDIR\QtQuick.2"
RMDir "$INSTDIR\platforms"
RMDir "$INSTDIR\imageformats"
RMDir "$INSTDIR"
RMDIR /r /REBOOTOK "$INSTDIR"
RMDIR /r /REBOOTOK "$LOCALAPPDATA\XXSof"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
Var UNINSTALL_PROG
Var OLD_VER
Var OLD_PATH
Function .onInit
FindProcDLL::FindProc "${PRODUCT_NAME}.exe"
Pop $R0
IntCmp $R0 1 0 no_run
MessageBox MB_ICONSTOP "安裝程式檢測到 ${PRODUCT_NAME} 正在執行,請退出程式後重試"
Quit
no_run:
;FunctionEnd
;Function .onInit
ClearErrors
ReadRegStr $UNINSTALL_PROG ${PRODUCT_UNINST_ROOT_KEY} ${PRODUCT_UNINST_KEY} "UninstallString"
IfErrors done
ReadRegStr $OLD_VER ${PRODUCT_UNINST_ROOT_KEY} ${PRODUCT_UNINST_KEY} "DisplayVersion"
MessageBox MB_YESNOCANCEL|MB_ICONQUESTION \
"檢測到本機已經安裝了 ${PRODUCT_NAME} $OLD_VER。\
$\n$\n是否先解除安裝已安裝的版本?" \
/SD IDYES \
IDYES uninstall \
IDNO done
Abort
uninstall:
StrCpy $OLD_PATH $UNINSTALL_PROG -10
ExecWait '"$UNINSTALL_PROG" /S _?=$OLD_PATH' $0
DetailPrint "uninst.exe returned $0"
Delete "$UNINSTALL_PROG"
RMDir $OLD_PATH
done:
FunctionEnd