setup without net40.nsi 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. ; 该脚本使用 HM VNISEdit 脚本编辑器向导产生
  2. !include "StrFunc.nsh"
  3. ${StrRep}
  4. ; 安装程序初始定义常量
  5. !define PRODUCT_NAME "MOKA Factory Tools"
  6. !define PRODUCT_VERSION "3.0.6.0"
  7. !define PRODUCT_PUBLISHER "MOKA"
  8. !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\MOKA Factory Tools.exe"
  9. !define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
  10. !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  11. !define PRODUCT_UNINST_ROOT_KEY "HKLM"
  12. SetCompressor lzma
  13. ; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
  14. !include "MUI.nsh"
  15. ; MUI 预定义常量
  16. !define MUI_ABORTWARNING
  17. !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
  18. !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
  19. ; 语言选择窗口常量设置
  20. !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
  21. !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
  22. !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
  23. ; 欢迎页面
  24. !insertmacro MUI_PAGE_WELCOME
  25. ; 许可协议页面
  26. !insertmacro MUI_PAGE_LICENSE "../Licence.txt"
  27. ; 安装目录选择页面
  28. !insertmacro MUI_PAGE_DIRECTORY
  29. ; 安装过程页面
  30. !insertmacro MUI_PAGE_INSTFILES
  31. ; 安装完成页面
  32. !define MUI_FINISHPAGE_RUN "$INSTDIR\MOKA Factory Tools.exe"
  33. !insertmacro MUI_PAGE_FINISH
  34. ; 安装卸载过程页面
  35. !insertmacro MUI_UNPAGE_INSTFILES
  36. ; 安装界面包含的语言设置
  37. !insertmacro MUI_LANGUAGE "English"
  38. !insertmacro MUI_LANGUAGE "SimpChinese"
  39. ; 安装预释放文件
  40. !insertmacro MUI_RESERVEFILE_LANGDLL
  41. !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
  42. ; ------ MUI 现代界面定义结束 ------
  43. Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
  44. OutFile "UpgradeSetup${PRODUCT_VERSION}.exe"
  45. InstallDir "$PROGRAMFILES\MOKA Factory Tools"
  46. InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
  47. ShowInstDetails show
  48. ShowUnInstDetails show
  49. Section "MainSection" SEC01
  50. SetOutPath "$INSTDIR"
  51. SetOverwrite ifnewer
  52. File "../bin\Release\System.Data.SQLite.xml"
  53. CreateDirectory "$SMPROGRAMS\MOKA Factory Tools"
  54. CreateShortCut "$SMPROGRAMS\MOKA Factory Tools\MOKA Factory Tools.lnk" "$INSTDIR\MOKA Factory Tools.exe"
  55. CreateShortCut "$DESKTOP\MOKA Factory Tools.lnk" "$INSTDIR\MOKA Factory Tools.exe"
  56. ;Delete "$INSTDIR\Config.json"
  57. File "../bin\Release\System.Data.SQLite.dll"
  58. File "../bin\Release\MOKA Factory Tools.exe"
  59. File "../bin\Release\MOKA Factory Tools.exe.config"
  60. File "../bin\Release\Newtonsoft.Json.dll"
  61. File "../bin\Release\Devaof.DB.SQLite.dll"
  62. File "../bin\Release\Devaof.DB.SqlBuilder.dll"
  63. File "../bin\Release\CSkin.xml"
  64. File "../bin\Release\CSkin.dll"
  65. ;File "../bin\Release\Config.json"
  66. SetOutPath "$INSTDIR\x86"
  67. File "../bin\Release\x86\*.*"
  68. SetOutPath "$INSTDIR\x64"
  69. File "../bin\Release\x64\*.*"
  70. SetOutPath "$INSTDIR\zh-CN"
  71. File "../bin\Release\zh-CN\*.*"
  72. SectionEnd
  73. Section -AdditionalIcons
  74. CreateShortCut "$SMPROGRAMS\MOKA Factory Tools\Uninstall.lnk" "$INSTDIR\uninst.exe"
  75. SectionEnd
  76. Section -Post
  77. WriteUninstaller "$INSTDIR\uninst.exe"
  78. WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\MOKA Factory Tools.exe"
  79. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  80. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  81. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\MOKA Factory Tools.exe"
  82. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  83. WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
  84. SectionEnd
  85. #-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#
  86. Function .onInit
  87. Call RemoveOld
  88. !insertmacro MUI_LANGDLL_DISPLAY
  89. FunctionEnd
  90. /******************************
  91. * 以下是安装程序的卸载部分 *
  92. ******************************/
  93. Section Uninstall
  94. Delete "$INSTDIR\uninst.exe"
  95. ;Delete "$INSTDIR\Config.json"
  96. Delete "$INSTDIR\CSkin.dll"
  97. Delete "$INSTDIR\CSkin.xml"
  98. Delete "$INSTDIR\Devaof.DB.SqlBuilder.dll"
  99. Delete "$INSTDIR\Devaof.DB.SQLite.dll"
  100. Delete "$INSTDIR\Newtonsoft.Json.dll"
  101. Delete "$INSTDIR\MOKA Factory Tools.exe"
  102. Delete "$INSTDIR\MOKA Factory Tools.exe.config"
  103. Delete "$INSTDIR\MOKA Fartory Tools Server.exe"
  104. Delete "$INSTDIR\MOKA Fartory Tools Server.exe.config"
  105. Delete "$INSTDIR\System.Data.SQLite.dll"
  106. Delete "$INSTDIR\System.Data.SQLite.xml"
  107. Delete "$SMPROGRAMS\MOKA Factory Tools\Uninstall.lnk"
  108. Delete "$DESKTOP\MOKA Factory Tools.lnk"
  109. Delete "$SMPROGRAMS\MOKA Factory Tools\MOKA Factory Tools.lnk"
  110. RMDir "$SMPROGRAMS\MOKA Factory Tools"
  111. RMDir "$INSTDIR"
  112. DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  113. DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
  114. SetAutoClose true
  115. SectionEnd
  116. #-- 根据 NSIS 脚本编辑规则,所有 Function 区段必须放置在 Section 区段之后编写,以避免安装程序出现未可预知的问题。--#
  117. Function un.onInit
  118. !insertmacro MUI_UNGETLANGUAGE
  119. MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "您确实要完全移除 $(^Name) ,及其所有的组件?" IDYES +2
  120. Abort
  121. FunctionEnd
  122. Function un.onUninstSuccess
  123. HideWindow
  124. MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从您的计算机移除。"
  125. FunctionEnd
  126. Function RemoveOld
  127. # 获取注册表信息;
  128. ReadRegStr $0 HKLM "${UNINSTALL_KEY}\SCBC Factory Tools" "UninstallString"
  129. ${IF} $0 != ""
  130. MessageBox MB_ICONINFORMATION|MB_OK "检测到旧的安装包,将会移除。"
  131. ${StrRep} $R1 $0 "\uninst.exe" ""
  132. # 复制文件;
  133. CopyFiles "$R1\Config.json" "$INSTDIR\Config.json"
  134. CopyFiles "$R1\Error.db" "$INSTDIR\Error.db"
  135. CopyFiles "$R1\Keys" "$INSTDIR\Keys"
  136. CopyFiles "$R1\log" "$INSTDIR\log"
  137. CopyFiles "$R1\download" "$INSTDIR\download"
  138. # 删除程序及注册表信息;
  139. Delete "$R1\uninst.exe"
  140. Delete "$R1\CSkin.dll"
  141. Delete "$R1\CSkin.xml"
  142. Delete "$R1\Devaof.DB.SqlBuilder.dll"
  143. Delete "$R1\Devaof.DB.SQLite.dll"
  144. Delete "$R1\Newtonsoft.Json.dll"
  145. Delete "$R1\SCBC Factory Tools.exe"
  146. Delete "$R1\SCBC Factory Tools.exe.config"
  147. Delete "$R1\SCBC Fartory Tools Server.exe"
  148. Delete "$R1\SCBC Fartory Tools Server.exe.config"
  149. Delete "$R1\System.Data.SQLite.dll"
  150. Delete "$R1\System.Data.SQLite.xml"
  151. Delete "$SMPROGRAMS\SCBC Factory Tools\Uninstall.lnk"
  152. Delete "$DESKTOP\SCBC Factory Tools.lnk"
  153. Delete "$SMPROGRAMS\SCBC Factory Tools\SCBC Factory Tools.lnk"
  154. RMDir "$SMPROGRAMS\SCBC Factory Tools"
  155. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SCBC Factory Tools"
  156. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\SCBC Factory Tools.exe"
  157. ${ENDIF}
  158. FunctionEnd