windows下nsis打包
2023-12-15 16:49:07
; Script generated by the HM NIS Edit Script Wizard.
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "AppTest"
!define PRODUCT_VERSION "1.0.0.1"
!define PRODUCT_PUBLISHER "AppTest, Inc."
!define PRODUCT_WEB_SITE "http://www.mycompany.com"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\AppTest.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 "../app.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
; lang setting view
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "../license/license.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\AppTest.exe"
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"
LangString LNG_AppName ${LANG_ENGLISH} "AppTest"
LangString LNG_AppName ${LANG_SIMPCHINESE} "AppTest"
LangString LNG_AppName ${LANG_TRADCHINESE} "AppTest"
LangString UNINSTALL_TIP ${LANG_ENGLISH} "Do you sure remove $(^Name) and components?"
LangString UNINSTALL_TIP ${LANG_SIMPCHINESE} "你确实要完全移除 $(^Name), 其及所有的组件?"
LangString UNINSTALL_TIP ${LANG_TRADCHINESE} "你確實要完全移除 $(^Name), 其及所有的組件?"
LangString UNINSTALL_CONFIRM ${LANG_ENGLISH} "Thank you very much! $(^Name) has been successfully removed."
LangString UNINSTALL_CONFIRM ${LANG_SIMPCHINESE} "非常感謝您的使用! $(^Name) 已成功地从您的计算机中移除。"
LangString UNINSTALL_CONFIRM ${LANG_TRADCHINESE} "非常感謝您的使用! $(^Name) 已成功地從您的計算機中移除。"
; MUI end ------
; get build time
!define /date BUILD_DATE %Y%m%d%H%M%S
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "AppTest_${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\AppTest"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
; set soft info
VIProductVersion "${PRODUCT_VERSION}" ; product version, it must if set soft ver
VIAddVersionKey "ProductName" "${PRODUCT_NAME}"; ; product name
;VIAddVersionKey "Comments" "comments”; ; comment
;VIAddVersionKey "companyName" "Company" ; company
;VIAddVersionKey "LegalTrademarks" "LegalTrademarks" ; LegalTrademarks
;VIAddVersionKey "LegalCopyright" "Copyright " ; copyright
VIAddVersionKey "FileDescription" "${PRODUCT_NAME}" ; file description
VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}_${BUILD_DATE}" ; file version
Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
; apps(dir: it must '\', not '/')
File /r "..\app\*.*"
; depends
File /r "..\depend\3rd\*.*"
File /r "..\depend/qt\*.*"
File /r "..\depend\windows\*.*"
; plugins
File /r "..\plugin\*.*"
CreateDirectory "$SMPROGRAMS\AppTest"
CreateShortCut "$SMPROGRAMS\AppTest\AppTest.lnk" "$INSTDIR\AppTest.exe"
CreateShortCut "$DESKTOP\AppTest.lnk" "$INSTDIR\AppTest.exe"
SectionEnd
Section -AdditionalIcons
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\AppTest\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\AppTest\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd
Section -Post
; save language type for select
;WriteRegStr HKCU ${LANGUAG_FLAG} "language" $LANGUAGE
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\AppTest.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\AppTest.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 .onInit
; select language(view)
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(UNINSTALL_CONFIRM)"
FunctionEnd
Function un.onInit
; read cache language type for install
ReadRegDWORD $LANGUAGE HKCU ${LANGUAG_FLAG} "language"
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UNINSTALL_TIP)" IDYES +2
Abort
FunctionEnd
Section Uninstall
Delete "$INSTDIR\${PRODUCT_NAME}.url"
; todo: stop process
Delete "$SMPROGRAMS\AppTest\Uninstall.lnk"
Delete "$SMPROGRAMS\AppTest\Website.lnk"
Delete "$DESKTOP\AppTest.lnk"
Delete "$SMPROGRAMS\AppTest\AppTest.lnk"
RMDir "$SMPROGRAMS\AppTest"
RMDir /r "$INSTDIR"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
文章来源:https://blog.csdn.net/Wite_Chen/article/details/135018511
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!