ui_laser_setup.nsh 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  1. 
  2. !include "StrFunc.nsh"
  3. !include "WordFunc.nsh"
  4. ${StrRep}
  5. ${StrStr}
  6. !include "LogicLib.nsh"
  7. !include "nsDialogs.nsh"
  8. !include "common.nsh"
  9. !include "x64.nsh"
  10. !include "MUI.nsh"
  11. !include "WinVer.nsh"
  12. !include "commonfunc.nsh"
  13. !insertmacro MUI_LANGUAGE "SimpChinese"
  14. VIProductVersion "${PRODUCT_VERSION}"
  15. VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
  16. VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
  17. VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}"
  18. VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
  19. VIAddVersionKey "InternalName" "${EXE_NAME}"
  20. VIAddVersionKey "FileDescription" "${PRODUCT_NAME}"
  21. VIAddVersionKey "LegalCopyright" "${PRODUCT_LEGAL}"
  22. !define INSTALL_PAGE_CONFIG 0
  23. ;!define INSTALL_PAGE_LICENSE 1
  24. !define INSTALL_PAGE_PROCESSING 1
  25. !define INSTALL_PAGE_FINISH 2
  26. !define INSTALL_PAGE_UNISTCONFIG 3
  27. !define INSTALL_PAGE_UNISTPROCESSING 4
  28. !define INSTALL_PAGE_UNISTFINISH 5
  29. Page custom DUIPage
  30. UninstPage custom un.DUIPage
  31. Var hInstallDlg
  32. Var hInstallSubDlg
  33. Var sCmdFlag
  34. Var sCmdSetupPath
  35. Var sSetupPath
  36. Var sReserveData
  37. Var InstallState
  38. Var UnInstallValue
  39. Var basedir
  40. Var datadir
  41. Var logError
  42. Var buildModelPath
  43. Var profilePath
  44. Var buildCallPath
  45. Var dbpath
  46. Var logpath
  47. Var binPath
  48. Var temp11
  49. Var temp12
  50. Var OLD_VER
  51. Var step
  52. ;在安装程序运行前的回调函数前实现
  53. Function .onInit
  54. System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
  55. Pop $R0
  56. StrCmp $R0 0 +3
  57. MessageBox MB_OK|MB_USERICON '有一个安装向导已经运行,请勿重复打开'
  58. Abort
  59. ${IfNot} ${AtLeastWin10}
  60. MessageBox MB_OK|MB_USERICON '本程序只能安装在windows-10(64位)系统上'
  61. Abort
  62. ${EndIf}
  63. ReadRegStr $OLD_VER HKLM "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_PATHNAME}" "DisplayVersion"
  64. ${IF} $OLD_VER != ""
  65. ${VersionCompare} $OLD_VER ${PRODUCT_VERSION} $R0
  66. ${If} $R0 == "0"
  67. MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
  68. Quit
  69. ${EndIf}
  70. ${If} $R0 == "1"
  71. MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
  72. ;MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},您安装的版本是 ${PRODUCT_VERSION} 小于版本 $OLD_VER '
  73. Quit
  74. ${EndIf}
  75. ${If} $R0 == "2"
  76. MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},版本 $OLD_VER 已安装在计算机中。如需重新安装,请卸载已有的安装'
  77. ;MessageBox MB_OK|MB_USERICON '${PRODUCT_PATHNAME},您安装的版本是 ${PRODUCT_VERSION} 大于版本 $OLD_VER '
  78. Quit
  79. ${EndIf}
  80. ${EndIf}
  81. FunctionEnd
  82. Function un.onInit
  83. System::Call 'kernel32::CreateMutexA(i 0, i 0, t"Winsnap_installer") i .r1 ?e'
  84. Pop $R0
  85. StrCmp $R0 0 +3
  86. MessageBox MB_OK|MB_USERICON '有一个卸载向导已经运行,请勿重复打开'
  87. Abort
  88. FunctionEnd
  89. Function DUIPage
  90. StrCpy $InstallState "0"
  91. InitPluginsDir
  92. SetOutPath "$PLUGINSDIR"
  93. File "${INSTALL_LICENCE_FILENAME}"
  94. File "${INSTALL_RES_PATH}"
  95. File /oname=logo.ico "${INSTALL_ICO}" #
  96. nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" "${INSTALL_LICENCE_FILENAME}"
  97. Pop $hInstallDlg
  98. Call GenerateSetupAddress
  99. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" "$INSTDIR\"
  100. Call OnRichEditTextChange
  101. nsNiuniuSkin::SetWindowTile $hInstallDlg "${PRODUCT_NAME}安装程序"
  102. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
  103. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licensename" "text" "《四维深时本地版用户许可协议》"
  104. Call BindUIControls
  105. nsNiuniuSkin::ShowPage 0
  106. FunctionEnd
  107. Function un.DUIPage
  108. StrCpy $InstallState "0"
  109. InitPluginsDir
  110. SetOutPath "$PLUGINSDIR"
  111. File "${INSTALL_RES_PATH}"
  112. File /oname=logo.ico "${UNINSTALL_ICO}"
  113. nsNiuniuSkin::InitSkinPage "$PLUGINSDIR\" ""
  114. Pop $hInstallDlg
  115. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTCONFIG}
  116. nsNiuniuSkin::SetWindowTile $hInstallDlg "${PRODUCT_NAME}卸载程序"
  117. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390s
  118. Call un.BindUnInstUIControls
  119. nsNiuniuSkin::SetControlAttribute $hInstallDlg "chkAutoRun" "selected" "true"
  120. nsNiuniuSkin::ShowPage 0
  121. FunctionEnd
  122. Function un.BindUnInstUIControls
  123. GetFunctionAddress $0 un.ExitDUISetup
  124. nsNiuniuSkin::BindCallBack $hInstallDlg "btnUninstalled" $0
  125. GetFunctionAddress $0 un.onUninstall
  126. nsNiuniuSkin::BindCallBack $hInstallDlg "btnUnInstall" $0
  127. GetFunctionAddress $0 un.ExitDUISetup
  128. nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
  129. GetFunctionAddress $0 un.OnBtnMin
  130. nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
  131. GetFunctionAddress $0 un.BtnDirPre
  132. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
  133. FunctionEnd
  134. Function BindUIControls
  135. GetFunctionAddress $0 OnExitDUISetup
  136. nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseClose" $0
  137. GetFunctionAddress $0 OnBtnMin
  138. nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseMin" $0
  139. GetFunctionAddress $0 OnBtnLicenseClick
  140. nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgreement" $0
  141. GetFunctionAddress $0 OnExitDUISetup
  142. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirClose" $0
  143. GetFunctionAddress $0 OnExitDUISetup
  144. nsNiuniuSkin::BindCallBack $hInstallDlg "btnLicenseCancel" $0
  145. GetFunctionAddress $0 OnBtnMin
  146. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirMin" $0
  147. GetFunctionAddress $0 OnBtnSelectDir
  148. nsNiuniuSkin::BindCallBack $hInstallDlg "btnSelectDir" $0
  149. GetFunctionAddress $0 OnBtnDirPre
  150. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirPre" $0
  151. GetFunctionAddress $0 OnBtnShowConfig
  152. nsNiuniuSkin::BindCallBack $hInstallDlg "btnAgree" $0
  153. GetFunctionAddress $0 OnBtnCancel
  154. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDirCancel" $0
  155. GetFunctionAddress $0 OnBtnInstall
  156. nsNiuniuSkin::BindCallBack $hInstallDlg "btnInstall" $0
  157. GetFunctionAddress $0 OnExitDUISetup
  158. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailClose" $0
  159. GetFunctionAddress $0 OnBtnMin
  160. nsNiuniuSkin::BindCallBack $hInstallDlg "btnDetailMin" $0
  161. GetFunctionAddress $0 OnFinished
  162. nsNiuniuSkin::BindCallBack $hInstallDlg "btnRun" $0
  163. GetFunctionAddress $0 OnBtnMin
  164. nsNiuniuSkin::BindCallBack $hInstallDlg "btnFinishedMin" $0
  165. GetFunctionAddress $0 OnExitDUISetup
  166. nsNiuniuSkin::BindCallBack $hInstallDlg "btnClose" $0
  167. GetFunctionAddress $0 OnCheckLicenseClick
  168. nsNiuniuSkin::BindCallBack $hInstallDlg "chkAgree" $0
  169. GetFunctionAddress $0 OnBtnShowMore
  170. nsNiuniuSkin::BindCallBack $hInstallDlg "btnShowMore" $0
  171. GetFunctionAddress $0 OnBtnHideMore
  172. nsNiuniuSkin::BindCallBack $hInstallDlg "btnHideMore" $0
  173. GetFunctionAddress $0 OnSysCommandCloseEvent
  174. nsNiuniuSkin::BindCallBack $hInstallDlg "syscommandclose" $0
  175. GetFunctionAddress $0 OnRichEditTextChange
  176. nsNiuniuSkin::BindCallBack $hInstallDlg "editDir" $0
  177. FunctionEnd
  178. Function OnRichEditTextChange
  179. nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
  180. Pop $0
  181. StrCpy $INSTDIR "$0"
  182. Call onVerifyInstDir
  183. Pop $0
  184. ${If} $0 == 1
  185. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "不能包含中文路径"
  186. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  187. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  188. goto TextChangeAbort
  189. ${EndIf}
  190. ${If} $0 == 2
  191. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "路径不能为空"
  192. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  193. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  194. goto TextChangeAbort
  195. ${EndIf}
  196. Call IsSetupPathIlleagal
  197. ${If} $R5 == "0"
  198. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "路径错误"
  199. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#ffff0000"
  200. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  201. goto TextChangeAbort
  202. ${EndIf}
  203. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "textcolor" "#FF999999"
  204. ${If} $R0 > 1024
  205. IntOp $R1 $R0 % 1024
  206. IntOp $R0 $R0 / 1024;
  207. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "剩余空间:$R0.$R1GB"
  208. ${Else}
  209. nsNiuniuSkin::SetControlAttribute $hInstallDlg "local_space" "text" "剩余空间:$R0.$R1MB"
  210. ${endif}
  211. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
  212. Pop $0
  213. ${If} $0 == "1"
  214. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
  215. ${Else}
  216. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  217. ${EndIf}
  218. TextChangeAbort:
  219. FunctionEnd
  220. Function OnCheckLicenseClick
  221. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
  222. Pop $0
  223. ${If} $0 == "0"
  224. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "true"
  225. ${Else}
  226. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnInstall" "enabled" "false"
  227. ${EndIf}
  228. FunctionEnd
  229. Function OnBtnLicenseClick
  230. ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_LICENSE}
  231. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "true"
  232. nsNiuniuSkin::GetControlAttribute $hInstallDlg "moreconfiginfo" "visible"
  233. Pop $0
  234. ${If} $0 = 0
  235. ;pos="10,35,560,405"
  236. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,385"
  237. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "270"
  238. ${Else}
  239. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "pos" "5,35,475,495"
  240. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editLicense" "height" "375"
  241. ${EndIf}
  242. FunctionEnd
  243. Section "silentInstallSec" SEC01
  244. #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent install code here."
  245. SectionEnd
  246. Function ShowMsgBox
  247. nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
  248. Pop $hInstallSubDlg
  249. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" "提示"
  250. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
  251. ${If} "$R7" == "1"
  252. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
  253. ${EndIf}
  254. nsNiuniuSkin::ShowSkinSubPage 0
  255. FunctionEnd
  256. Function OnBtnInstall
  257. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkAgree" "selected"
  258. Pop $0
  259. StrCpy $0 "1"
  260. StrCmp $0 "0" InstallAbort 0
  261. nsProcess::_FindProcess "${EXE_NAME_EXT}"
  262. Pop $R0
  263. ${If} $R0 == 0
  264. StrCpy $R8 "${PRODUCT_NAME} 正在运行,请退出后重试!"
  265. StrCpy $R7 "0"
  266. Call ShowMsgBox
  267. goto InstallAbort
  268. ${EndIf}
  269. nsNiuniuSkin::GetControlAttribute $hInstallDlg "editDir" "text"
  270. Pop $0
  271. StrCmp $0 "" InstallAbort 0
  272. Call AdjustInstallPath
  273. StrCpy $sSetupPath "$INSTDIR"
  274. Call IsSetupPathIlleagal
  275. ${If} $R5 == "0"
  276. StrCpy $R8 "路径错误,请使用正确的路径安装!"
  277. StrCpy $R7 "0"
  278. Call ShowMsgBox
  279. goto InstallAbort
  280. ${EndIf}
  281. ${If} $R5 == "-1"
  282. StrCpy $R8 "目标磁盘空间不足,请使用其他的磁盘安装!"
  283. StrCpy $R7 "0"
  284. Call ShowMsgBox
  285. goto InstallAbort
  286. ${EndIf}
  287. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
  288. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
  289. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_PROCESSING}
  290. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "min" "0"
  291. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "max" "100"
  292. #Call BakFiles
  293. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "正在安装"
  294. GetFunctionAddress $0 ExtractFunc
  295. BgWorker::CallAndWait
  296. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkShotcut" "selected"
  297. #Pop $R0
  298. # ${If} $R0 == "1"
  299. # SetShellVarContext all
  300. # CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
  301. # SetShellVarContext current
  302. # ${EndIf}
  303. SetShellVarContext all
  304. CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${EXE_NAME}"
  305. SetShellVarContext current
  306. Call CreateAppShortcut
  307. Call CreateUninstall
  308. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
  309. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "正在初始化..."
  310. GetFunctionAddress $0 OnEnvInstall
  311. BgWorker::CallAndWait
  312. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "正在初始化服务..."
  313. GetFunctionAddress $0 installService
  314. BgWorker::CallAndWait
  315. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_tip" "text" "初始化完成"
  316. StrCpy $InstallState "1"
  317. #Call OnFinished
  318. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_FINISH}
  319. InstallAbort:
  320. FunctionEnd
  321. Function ExtractCallback
  322. Pop $1
  323. Pop $2
  324. System::Int64Op $1 * 100
  325. Pop $3
  326. System::Int64Op $3 / $2
  327. Pop $0
  328. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "$0"
  329. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "$0%"
  330. ${If} $1 == $2
  331. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrProgress" "value" "100"
  332. nsNiuniuSkin::SetControlAttribute $hInstallDlg "progress_pos" "text" "100%"
  333. ${EndIf}
  334. FunctionEnd
  335. Function OnSysCommandCloseEvent
  336. Call OnExitDUISetup
  337. FunctionEnd
  338. Function OnExitDUISetup
  339. ${If} $InstallState == "0"
  340. StrCpy $R8 "确定要停止安装吗?"
  341. StrCpy $R7 "1"
  342. Call ShowMsgBox
  343. pop $0
  344. ${If} $0 == 0
  345. goto endfun
  346. ${EndIf}
  347. ${EndIf}
  348. nsNiuniuSkin::ExitDUISetup
  349. endfun:
  350. FunctionEnd
  351. Function OnBtnMin
  352. SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
  353. FunctionEnd
  354. Function OnBtnCancel
  355. nsNiuniuSkin::ExitDUISetup
  356. FunctionEnd
  357. Function OnEnvInstall
  358. EnVar::SetHKLM
  359. EnVar::AddValue FDMGEA_HOME "$INSTDIR"
  360. EnVar::SetHKLM
  361. EnVar::AddValue JAVA_HOME "$INSTDIR\jdk1.8"
  362. EnVar::SetHKLM
  363. EnVar::AddValue MYSQL_HOME "$INSTDIR\mysql"
  364. EnVar::SetHKLM
  365. EnVar::AddValue REDIS_HOME "$INSTDIR\redis"
  366. EnVar::SetHKLM
  367. EnVar::AddValue 4DKK_HOME "$INSTDIR\CGAII"
  368. EnVar::SetHKLM
  369. EnVar::AddValue MONGODB_HOME "$INSTDIR\mongodb"
  370. EnVar::SetHKLM
  371. EnVar::AddValue CLASS_PATH ".;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
  372. EnVar::SetHKLM
  373. EnVar::AddValue "Path" "$INSTDIR\jdk1.8\bin;$INSTDIR\mysql\bin;$INSTDIR\mongodb\bin;$INSTDIR\redis;$INSTDIR\CGAII;$INSTDIR\CGAII\lib;"
  374. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  375. ;nsExec::ExecToStack '"$INSTDIR\tools\env_install.bat" $INSTDIR '
  376. FunctionEnd
  377. Function un.OnEnvDownInstall
  378. EnVar::SetHKLM
  379. EnVar::Delete "FDMGEA_HOME" "$INSTDIR"
  380. EnVar::Delete "JAVA_HOME" "$INSTDIR\jdk1.8"
  381. EnVar::Delete "MYSQL_HOME" "$INSTDIR\mysql"
  382. EnVar::Delete "REDIS_HOME" "$INSTDIR\redis"
  383. EnVar::Delete "4DKK_HOME" "$INSTDIR\CGAII"
  384. EnVar::Delete "MONGODB_HOME" "$INSTDIR\mongodb"
  385. EnVar::Delete "CLASS_PATH" "%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar"
  386. EnVar::DeleteValue "PATH" "%JAVA_HOME%\bin"
  387. EnVar::DeleteValue "PATH" "%MYSQL_HOME%\bin"
  388. EnVar::DeleteValue "PATH" "%MONGODB_HOME%\bin"
  389. EnVar::DeleteValue "PATH" "%REDIS_HOME%"
  390. EnVar::DeleteValue "PATH" "%4DKK_HOME%"
  391. EnVar::DeleteValue "PATH" "%4DKK_HOME%\lib"
  392. ;nsExec::ExecToStack '"$INSTDIR\tools\uninstall.bat" $INSTDIR '
  393. FunctionEnd
  394. Function un.installService
  395. ${If} $sReserveData == 1
  396. CreateDirectory $INSTDIR\USER_DATA\static
  397. CreateDirectory $INSTDIR\USER_DATA\pro
  398. CopyFiles /SILENT $INSTDIR\4DKK_PROGRAM_STATIC\*.* $INSTDIR\USER_DATA\static
  399. CopyFiles /SILENT $INSTDIR\4DKK_PROGRAM_DATA\*.* $INSTDIR\USER_DATA\pro
  400. ${EndIf}
  401. nsExec::ExecToStack '"$INSTDIR\tools\unservice.bat" $INSTDIR '
  402. SimpleSC::ExistsService "lasermongodb"
  403. Pop $0
  404. ${If} $0 == 0
  405. SimpleSC::StopService "lasermongodb" 0 30
  406. SimpleSC::RemoveService "lasermongodb"
  407. ${EndIf}
  408. SimpleSC::ExistsService "lasermysql"
  409. Pop $0
  410. ${If} $0 == 0
  411. SimpleSC::StopService "lasermysql" 0 30
  412. SimpleSC::RemoveService "lasermysql"
  413. ${EndIf}
  414. SimpleSC::ExistsService "laserredis"
  415. Pop $0
  416. ${If} $0 == 0
  417. SimpleSC::StopService "laserredis" 0 30
  418. SimpleSC::RemoveService "laserredis"
  419. ${EndIf}
  420. FunctionEnd
  421. Function installService
  422. ${StrRep} $0 '$INSTDIR\mysql' '\' '\\'
  423. StrCpy $basedir $0
  424. ${StrRep} $0 '$INSTDIR\mysql\data' '\' '\\'
  425. StrCpy $datadir $0
  426. ${StrRep} $0 '$INSTDIR\mysql\logs.log' '\' '\\'
  427. StrCpy $logError $0
  428. WriteINIStr $INSTDIR\mysql\my.ini mysqld port 3307
  429. WriteINIStr $INSTDIR\mysql\my.ini mysqld basedir $basedir
  430. WriteINIStr $INSTDIR\mysql\my.ini mysqld datadir $datadir
  431. WriteINIStr $INSTDIR\mysql\my.ini mysqld log-error $logError
  432. WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connections 1000
  433. WriteINIStr $INSTDIR\mysql\my.ini mysqld max_connect_errors 10
  434. WriteINIStr $INSTDIR\mysql\my.ini mysqld character-set-server utf8mb4
  435. WriteINIStr $INSTDIR\mysql\my.ini mysqld default-storage-engine INNODB
  436. WriteINIStr $INSTDIR\mysql\my.ini mysqld default_authentication_plugin mysql_native_password
  437. WriteINIStr $INSTDIR\mysql\my.ini mysqld local_infile ON
  438. WriteINIStr $INSTDIR\mysql\my.ini mysql default-character-set utf8mb4
  439. WriteINIStr $INSTDIR\mysql\my.ini mysql local_infile ON
  440. WriteINIStr $INSTDIR\mysql\my.ini client port 3307
  441. WriteINIStr $INSTDIR\mysql\my.ini client default-character-set utf8mb4
  442. Sleep 2000
  443. SetOutPath "$INSTDIR\mysql\bin"
  444. nsExec::ExecToStack 'cmd.exe /c "$INSTDIR/mysql/bin/mysqld.exe" --initialize-insecure --lower-case-table-names=1'
  445. nsExec::ExecToStack 'cmd.exe /c "$INSTDIR/mysql/bin/mysqld.exe" -install lasermysql'
  446. SimpleSC::StartService "lasermysql" "" 30
  447. SetOutPath "$INSTDIR\redis"
  448. nsExec::ExecToStack '"cmd.exe" /c redis-server.exe --service-install "$INSTDIR\redis\redis.windows.conf" --service-name laserredis --loglevel verbose'
  449. SimpleSC::StartService "laserredis" "" 30
  450. nsExec::ExecToStack '"cmd.exe" /c sc config laserredis start=auto'
  451. SimpleSC::RestartService "laserredis" "" 30
  452. Sleep 2000
  453. SetOutPath "$INSTDIR\mongodb"
  454. ${StrRep} $0 '$INSTDIR\mongodb\db' '\' '\\'
  455. StrCpy $dbpath $0
  456. ${StrRep} $0 '$INSTDIR\mongodb\logs\mongo.log' '\' '\\'
  457. StrCpy $logpath $0
  458. FileOpen $0 $INSTDIR\mongodb\mongo.conf w
  459. IfErrors done
  460. FileWrite $0 'port=29031$\n'
  461. FileWrite $0 'dbpath=$dbpath$\n'
  462. FileWrite $0 'logpath=$logpath$\n'
  463. FileWrite $0 'logappend=true$\n'
  464. FileWrite $0 'maxConns=1000$\n'
  465. FileClose $0
  466. done:
  467. nsExec::ExecToStack '"cmd.exe" /c sc create lasermongodb binpath= "$INSTDIR\mongodb\bin\mongod.exe --config $INSTDIR\mongodb\mongo.conf --service" start= auto'
  468. SimpleSC::StartService "lasermongodb" "" 30
  469. Sleep 2000
  470. IfFileExists "$INSTDIR\USER_DATA\static\*.*" 0 static_not_found
  471. CopyFiles /SILENT $INSTDIR\USER_DATA\static\*.* $INSTDIR\4DKK_PROGRAM_STATIC
  472. RMDir /r "$INSTDIR\USER_DATA\static"
  473. goto static_end_of
  474. static_not_found:
  475. goto static_end_of
  476. static_end_of:
  477. IfFileExists "$INSTDIR\USER_DATA\pro\*.*" 0 pro_not_found
  478. CopyFiles /SILENT $INSTDIR\USER_DATA\pro\*.* $INSTDIR\4DKK_PROGRAM_DATA
  479. RMDir /r "$INSTDIR\USER_DATA\pro"
  480. goto pro_end_of
  481. pro_not_found:
  482. goto pro_end_of
  483. pro_end_of:
  484. Sleep 2000
  485. ;
  486. ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_DATA\' '\' '\\'
  487. StrCpy $buildModelPath $0
  488. ${StrRep} $0 '$INSTDIR\4DKK_PROGRAM_STATIC\' '\' '\\'
  489. StrCpy $profilePath $0
  490. ${StrRep} $0 '$INSTDIR\CGAII' '\' '\\'
  491. StrCpy $buildCallPath $0
  492. ${StrRep} $0 '$INSTDIR\bin\resources\static' '\' '\\'
  493. StrCpy $binPath $0
  494. nsJSON::Set /file $INSTDIR\bin\resources\static\setting.json
  495. nsJSON::Set /value `{}`
  496. nsJSON::Set `sceneConfig` /value `"config.json"`
  497. nsJSON::Set `sceheKey` /value `"id"`
  498. nsJSON::Set `sceneBundle` /value `"./build.zip"`
  499. nsJSON::Set `sceneBundleDir` /value `"capture"`
  500. nsJSON::Set `buildModelPath` /value `"$buildModelPath"`
  501. nsJSON::Set `javaPort` /value `9000`
  502. nsJSON::Set `profilePath` /value `"$profilePath"`
  503. nsJSON::Set `buildCallPath` /value `"$buildCallPath"`
  504. nsJSON::Set `binPath` /value `"$binPath"`
  505. nsJSON::Serialize /format /file $INSTDIR\bin\resources\static\setting.json
  506. nsExec::ExecToStack '"$INSTDIR\tools\service.bat" $INSTDIR '
  507. functionend
  508. Function OnFinished
  509. #MessageBox MB_YESNO|MB_ICONQUESTION "需要重启系统才能完成安装" IDNO +2
  510. #Reboot
  511. #Exec "$INSTDIR${EXE_NAME}"
  512. Call OnExitDUISetup
  513. FunctionEnd
  514. Function OnBtnSelectDir
  515. nsNiuniuSkin::SelectInstallDirEx $hInstallDlg "请选择安装路径"
  516. Pop $0
  517. ${Unless} "$0" == ""
  518. nsNiuniuSkin::SetControlAttribute $hInstallDlg "editDir" "text" $0
  519. ${EndUnless}
  520. FunctionEnd
  521. Function StepHeightSizeAsc
  522. ${ForEach} $R0 390 500 + 10
  523. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
  524. Sleep 5
  525. ${Next}
  526. FunctionEnd
  527. Function StepHeightSizeDsc
  528. ${ForEach} $R0 480 390 - 10
  529. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 $R0
  530. Sleep 5
  531. ${Next}
  532. FunctionEnd
  533. Function OnBtnShowMore
  534. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
  535. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
  536. nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "true"
  537. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "true"
  538. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "false"
  539. GetFunctionAddress $0 StepHeightSizeAsc
  540. BgWorker::CallAndWait
  541. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 500
  542. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
  543. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
  544. FunctionEnd
  545. Function OnBtnHideMore
  546. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "false"
  547. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "false"
  548. nsNiuniuSkin::SetControlAttribute $hInstallDlg "moreconfiginfo" "visible" "false"
  549. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "visible" "false"
  550. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "visible" "true"
  551. GetFunctionAddress $0 StepHeightSizeDsc
  552. BgWorker::CallAndWait
  553. nsNiuniuSkin::SetWindowSize $hInstallDlg 480 390
  554. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnShowMore" "enabled" "true"
  555. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnHideMore" "enabled" "true"
  556. FunctionEnd
  557. Function OnBtnShowConfig
  558. ;nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_CONFIG}
  559. nsNiuniuSkin::SetControlAttribute $hInstallDlg "licenseshow" "visible" "false"
  560. FunctionEnd
  561. Function OnBtnDirPre
  562. StrCpy $R8 "确定要取消四维深时本地版安装吗?"
  563. StrCpy $R7 "0"
  564. Call ShowMsgBox
  565. ;nsNiuniuSkin::PrePage "wizardTab"
  566. FunctionEnd
  567. Function un.BtnDirPre
  568. StrCpy $R8 "确定要取消四维深时本地版卸载吗?"
  569. StrCpy $R7 "0"
  570. Call un.ShowMsgBox
  571. ;nsNiuniuSkin::PrePage "wizardTab"
  572. FunctionEnd
  573. Function un.ShowMsgBox
  574. nsNiuniuSkin::InitSkinSubPage "msgBox.xml" "btnOK" "btnCancel,btnClose"
  575. Pop $hInstallSubDlg
  576. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblTitle" "text" "提示"
  577. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "lblMsg" "text" "$R8"
  578. ${If} "$R7" == "1"
  579. nsNiuniuSkin::SetControlAttribute $hInstallSubDlg "hlCancel" "visible" "true"
  580. ${EndIf}
  581. nsNiuniuSkin::ShowSkinSubPage 0
  582. FunctionEnd
  583. Function un.ExitDUISetup
  584. nsNiuniuSkin::ExitDUISetup
  585. FunctionEnd
  586. Function un.OnBtnMin
  587. SendMessage $hInstallDlg ${WM_SYSCOMMAND} 0xF020 0
  588. FunctionEnd
  589. Section "un.silentInstallSec" SEC02
  590. #MessageBox MB_OK|MB_ICONINFORMATION "Test silent install. you can add your silent uninstall code here."
  591. SectionEnd
  592. Function un.onUninstall
  593. nsProcess::_FindProcess "${EXE_NAME_EXT}"
  594. Pop $R0
  595. ${If} $R0 == 0
  596. StrCpy $R8 "${PRODUCT_NAME} 正在运行,请退出后重试!"
  597. StrCpy $R7 "0"
  598. Call un.ShowMsgBox
  599. goto InstallAbort
  600. ${EndIf}
  601. nsNiuniuSkin::GetControlAttribute $hInstallDlg "chkbox_userdata" "selected"
  602. Pop $0
  603. StrCpy $sReserveData $0
  604. ${If} $sReserveData == 1
  605. CreateDirectory $INSTDIR\USER_DATA
  606. ${EndIf}
  607. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "false"
  608. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTPROCESSING}
  609. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "min" "0"
  610. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "max" "100"
  611. IntOp $UnInstallValue 0 + 1
  612. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" "正在初始化卸载..."
  613. GetFunctionAddress $0 un.OnEnvDownInstall
  614. BgWorker::CallAndWait
  615. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" "正在卸载服务..."
  616. GetFunctionAddress $0 un.installService
  617. BgWorker::CallAndWait
  618. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_tip" "text" "正在卸载..."
  619. Call un.DeleteShotcutAndInstallInfo
  620. IntOp $UnInstallValue $UnInstallValue + 8
  621. GetFunctionAddress $0 un.RemoveFiles
  622. BgWorker::CallAndWait
  623. InstallAbort:
  624. FunctionEnd
  625. Function un.RemoveFiles
  626. ${Locate} "$INSTDIR" "/G=0 /M=*.*" "un.onDeleteFileFound"
  627. StrCpy $InstallState "1"
  628. nsNiuniuSkin::SetControlAttribute $hInstallDlg "btnClose" "enabled" "true"
  629. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
  630. nsNiuniuSkin::ShowPageItem $hInstallDlg "wizardTab" ${INSTALL_PAGE_UNISTFINISH}
  631. FunctionEnd
  632. Function un.onDeleteFileFound
  633. ; $R9 "path\name"
  634. ; $R8 "path"
  635. ; $R7 "name"
  636. ; $R6 "size" ($R6 = "" if directory, $R6 = "0" if file with /S=)
  637. ${If} $sReserveData == 0
  638. Delete "$R9"
  639. RMDir /r "$R9"
  640. RMDir "$R9"
  641. ${EndIf}
  642. ${If} $sReserveData == 1
  643. RMDir /r "$R8\bin"
  644. RMDir /r "$R8\CGAII"
  645. RMDir /r "$R8\mongodb"
  646. RMDir /r "$R8\mysql"
  647. RMDir /r "$R8\redis"
  648. RMDir /r "$R8\jdk1.8"
  649. RMDir /r "$R8\4DKK_PROGRAM_STATIC"
  650. RMDir /r "$R8\4DKK_PROGRAM_DATA"
  651. RMDir /r "$R8\tools"
  652. ${EndIf}
  653. IntOp $UnInstallValue $UnInstallValue + 2
  654. ${If} $UnInstallValue > 100
  655. IntOp $UnInstallValue 100 + 0
  656. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "100"
  657. ${Else}
  658. nsNiuniuSkin::SetControlAttribute $hInstallDlg "slrUnInstProgress" "value" "$UnInstallValue"
  659. nsNiuniuSkin::SetControlAttribute $hInstallDlg "un_progress_pos" "text" "$UnInstallValue%"
  660. #Sleep 100
  661. ${EndIf}
  662. undelete:
  663. Push "LocateNext"
  664. FunctionEnd
  665. #
  666. # 以 Unicode 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
  667. # 但建议 Unicode 版本优先使用此函数。
  668. #
  669. Function PathIsDBCS_W
  670. Exch $R0
  671. Push $R1
  672. Push $R2
  673. Push $R3
  674. System::Call "*(&w${NSIS_MAX_STRLEN}R0)p.R1"
  675. StrCpy $R0 0
  676. StrCpy $R2 $R1
  677. lbl_loop:
  678. # Unicode 版取 2 个字节长度的字符,字符串遇到 0 字符表示结束了。
  679. System::Call "*$R2(&i2.R3)"
  680. IntCmp $R3 0 lbl_done
  681. # Unicode 字符直接判断字符值,大于 128 的我们就视为非英文字符。
  682. IntCmp $R3 128 0 lbl_skip
  683. IntOp $R0 $R0 !
  684. Goto lbl_done
  685. lbl_skip:
  686. # 如果用 NSIS 3.x 这里可以用 IntPtrOp 代替。
  687. IntOp $R2 $R2 + 2
  688. Goto lbl_loop
  689. lbl_done:
  690. System::Free $R1
  691. Pop $R3
  692. Pop $R2
  693. Pop $R1
  694. Exch $R0
  695. FunctionEnd
  696. #
  697. # 以 ANSI 字符串的方式进行判断 (与 NSIS 是 ANSI/Unicode 无关)
  698. # 但建议 ANSI 版本优先使用此函数。
  699. #
  700. Function PathIsDBCS_A
  701. Exch $R0
  702. Push $R1
  703. Push $R2
  704. Push $R3
  705. Push $R4
  706. System::Call "*(&m${NSIS_MAX_STRLEN}R0)p.R1"
  707. StrCpy $R0 0
  708. StrCpy $R2 $R1
  709. lbl_loop:
  710. # ANSI 版取 1 个字节长度的字符,字符串遇到 0 字符表示结束了。
  711. System::Call "*$R2(&i1.R3)"
  712. IntCmp $R3 0 lbl_done
  713. # ANSI 字符用 IsDBCSLeadByte 判断是否双字节字符的前导字节。
  714. System::Call "kernel32::IsDBCSLeadByte(iR3)i.R4"
  715. IntCmp $R4 0 lbl_skip
  716. IntOp $R0 $R0 !
  717. Goto lbl_done
  718. lbl_skip:
  719. # 用 CharNextA 得到下一个字符的地址 (可正确处理双字节字符)。
  720. System::Call "user32::CharNextA(pR2)p.R2"
  721. Goto lbl_loop
  722. lbl_done:
  723. Pop $R4
  724. Pop $R3
  725. Pop $R2
  726. Pop $R1
  727. Exch $R0
  728. FunctionEnd
  729. #
  730. # 当选择的安装路径变更时,路径为空或包含双字节字符 (不限于简体中文),都不允许继续。
  731. # 路径为空时,NSIS 会自行判断。
  732. #
  733. # 此示例未判断是否包含空格。如有需要,请与示例一配合使用。
  734. #
  735. Function onVerifyInstDir
  736. # 检查安装路径是否包含双字节字符 (不限于简体中文)。
  737. StrCpy $0 $INSTDIR
  738. StrLen $1 $0
  739. # 这里也可以换成 PathIsDBCS_A 以测试效果。
  740. ${If} $1 == 0
  741. Push 2
  742. ${Else}
  743. Push $INSTDIR
  744. Call PathIsDBCS_A
  745. Pop $R0
  746. Push $R0
  747. ${endif}
  748. lbl_done:
  749. FunctionEnd
  750. Function isEmptyDir
  751. # Stack -> # Stack: <directory>
  752. Exch $0 # Stack: $0
  753. Push $1 # Stack: $1, $0
  754. FindFirst $0 $1 "$0\*.*"
  755. strcmp $1 "." 0 _notempty
  756. FindNext $0 $1
  757. strcmp $1 ".." 0 _notempty
  758. ClearErrors
  759. FindNext $0 $1
  760. IfErrors 0 _notempty
  761. FindClose $0
  762. Pop $1 # Stack: $0
  763. StrCpy $0 1
  764. Exch $0 # Stack: 1 (true)
  765. goto _end
  766. _notempty:
  767. FindClose $0
  768. ClearErrors
  769. Pop $1 # Stack: $0
  770. StrCpy $0 0
  771. Exch $0 # Stack: 0 (false)
  772. _end:
  773. FunctionEnd
  774. Function un.isEmptyDir
  775. # Stack -> # Stack: <directory>
  776. Exch $0 # Stack: $0
  777. Push $1 # Stack: $1, $0
  778. FindFirst $0 $1 "$0\*.*"
  779. strcmp $1 "." 0 _notempty
  780. FindNext $0 $1
  781. strcmp $1 ".." 0 _notempty
  782. ClearErrors
  783. FindNext $0 $1
  784. IfErrors 0 _notempty
  785. FindClose $0
  786. Pop $1 # Stack: $0
  787. StrCpy $0 1
  788. Exch $0 # Stack: 1 (true)
  789. goto _end
  790. _notempty:
  791. FindClose $0
  792. ClearErrors
  793. Pop $1 # Stack: $0
  794. StrCpy $0 0
  795. Exch $0 # Stack: 0 (false)
  796. _end:
  797. FunctionEnd