NSIS.template64.in 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  1. ; CPack install script designed for a nmake build
  2. ;--------------------------------
  3. ; You must define these values
  4. !define VERSION "@CPACK_PACKAGE_VERSION@"
  5. !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@"
  6. !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
  7. ;--------------------------------
  8. ;Variables
  9. Var MUI_TEMP
  10. Var STARTMENU_FOLDER
  11. Var SV_ALLUSERS
  12. Var START_MENU
  13. Var DO_NOT_ADD_TO_PATH
  14. Var ADD_TO_PATH_ALL_USERS
  15. Var ADD_TO_PATH_CURRENT_USER
  16. Var INSTALL_DESKTOP
  17. Var IS_DEFAULT_INSTALLDIR
  18. ;--------------------------------
  19. ;Include Modern UI
  20. !include "MUI.nsh"
  21. ;Default installation folder
  22. ;InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
  23. InstallDir "$PROGRAMFILES64\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
  24. ;--------------------------------
  25. ;General
  26. ;Name and file
  27. Name "@CPACK_NSIS_PACKAGE_NAME@"
  28. OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
  29. ;Set compression
  30. SetCompressor @CPACK_NSIS_COMPRESSOR@
  31. @CPACK_NSIS_DEFINES@
  32. !include Sections.nsh
  33. ;--- Component support macros: ---
  34. ; The code for the add/remove functionality is from:
  35. ; http://nsis.sourceforge.net/Add/Remove_Functionality
  36. ; It has been modified slightly and extended to provide
  37. ; inter-component dependencies.
  38. Var AR_SecFlags
  39. Var AR_RegFlags
  40. @CPACK_NSIS_SECTION_SELECTED_VARS@
  41. ; Loads the "selected" flag for the section named SecName into the
  42. ; variable VarName.
  43. !macro LoadSectionSelectedIntoVar SecName VarName
  44. SectionGetFlags ${${SecName}} $${VarName}
  45. IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits
  46. !macroend
  47. ; Loads the value of a variable... can we get around this?
  48. !macro LoadVar VarName
  49. IntOp $R0 0 + $${VarName}
  50. !macroend
  51. ; Sets the value of a variable
  52. !macro StoreVar VarName IntValue
  53. IntOp $${VarName} 0 + ${IntValue}
  54. !macroend
  55. !macro InitSection SecName
  56. ; This macro reads component installed flag from the registry and
  57. ;changes checked state of the section on the components page.
  58. ;Input: section index constant name specified in Section command.
  59. ClearErrors
  60. ;Reading component status from registry
  61. ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)\Components\${SecName}" "Installed"
  62. IfErrors "default_${SecName}"
  63. ;Status will stay default if registry value not found
  64. ;(component was never installed)
  65. IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits
  66. SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags
  67. IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off
  68. IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit
  69. ; Note whether this component was installed before
  70. !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
  71. IntOp $R0 $AR_RegFlags & $AR_RegFlags
  72. ;Writing modified flags
  73. SectionSetFlags ${${SecName}} $AR_SecFlags
  74. "default_${SecName}:"
  75. !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
  76. !macroend
  77. !macro FinishSection SecName
  78. ; This macro reads section flag set by user and removes the section
  79. ;if it is not selected.
  80. ;Then it writes component installed flag to registry
  81. ;Input: section index constant name specified in Section command.
  82. SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags
  83. ;Checking lowest bit:
  84. IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED}
  85. IntCmp $AR_SecFlags 1 "leave_${SecName}"
  86. ;Section is not selected:
  87. ;Calling Section uninstall macro and writing zero installed flag
  88. !insertmacro "Remove_${${SecName}}"
  89. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)\Components\${SecName}" \
  90. "Installed" 0
  91. Goto "exit_${SecName}"
  92. "leave_${SecName}:"
  93. ;Section is selected:
  94. WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)\Components\${SecName}" \
  95. "Installed" 1
  96. "exit_${SecName}:"
  97. !macroend
  98. !macro RemoveSection SecName
  99. ; This macro is used to call section's Remove_... macro
  100. ;from the uninstaller.
  101. ;Input: section index constant name specified in Section command.
  102. !insertmacro "Remove_${${SecName}}"
  103. !macroend
  104. ; Determine whether the selection of SecName changed
  105. !macro MaybeSelectionChanged SecName
  106. !insertmacro LoadVar ${SecName}_selected
  107. SectionGetFlags ${${SecName}} $R1
  108. IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits
  109. ; See if the status has changed:
  110. IntCmp $R0 $R1 "${SecName}_unchanged"
  111. !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
  112. IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
  113. !insertmacro "Deselect_required_by_${SecName}"
  114. goto "${SecName}_unchanged"
  115. "${SecName}_was_selected:"
  116. !insertmacro "Select_${SecName}_depends"
  117. "${SecName}_unchanged:"
  118. !macroend
  119. ;--- End of Add/Remove macros ---
  120. ;--------------------------------
  121. ;Interface Settings
  122. !define MUI_HEADERIMAGE
  123. !define MUI_ABORTWARNING
  124. ;--------------------------------
  125. ; path functions
  126. !verbose 3
  127. !include "WinMessages.NSH"
  128. !verbose 4
  129. ;----------------------------------------
  130. ; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
  131. ;----------------------------------------
  132. !verbose 3
  133. !include "WinMessages.NSH"
  134. !verbose 4
  135. ;====================================================
  136. ; get_NT_environment
  137. ; Returns: the selected environment
  138. ; Output : head of the stack
  139. ;====================================================
  140. !macro select_NT_profile UN
  141. Function ${UN}select_NT_profile
  142. StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
  143. DetailPrint "Selected environment for all users"
  144. Push "all"
  145. Return
  146. environment_single:
  147. DetailPrint "Selected environment for current user only."
  148. Push "current"
  149. Return
  150. FunctionEnd
  151. !macroend
  152. !insertmacro select_NT_profile ""
  153. !insertmacro select_NT_profile "un."
  154. ;----------------------------------------------------
  155. !define NT_current_env 'HKCU "Environment"'
  156. !define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
  157. !ifndef WriteEnvStr_RegKey
  158. !ifdef ALL_USERS
  159. !define WriteEnvStr_RegKey \
  160. 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
  161. !else
  162. !define WriteEnvStr_RegKey 'HKCU "Environment"'
  163. !endif
  164. !endif
  165. ; AddToPath - Adds the given dir to the search path.
  166. ; Input - head of the stack
  167. ; Note - Win9x systems requires reboot
  168. Function AddToPath
  169. Exch $0
  170. Push $1
  171. Push $2
  172. Push $3
  173. # don't add if the path doesn't exist
  174. IfFileExists "$0\*.*" "" AddToPath_done
  175. ReadEnvStr $1 PATH
  176. ; if the path is too long for a NSIS variable NSIS will return a 0
  177. ; length string. If we find that, then warn and skip any path
  178. ; modification as it will trash the existing path.
  179. StrLen $2 $1
  180. IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done
  181. CheckPathLength_ShowPathWarning:
  182. Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!"
  183. Goto AddToPath_done
  184. CheckPathLength_Done:
  185. Push "$1;"
  186. Push "$0;"
  187. Call StrStr
  188. Pop $2
  189. StrCmp $2 "" "" AddToPath_done
  190. Push "$1;"
  191. Push "$0\;"
  192. Call StrStr
  193. Pop $2
  194. StrCmp $2 "" "" AddToPath_done
  195. GetFullPathName /SHORT $3 $0
  196. Push "$1;"
  197. Push "$3;"
  198. Call StrStr
  199. Pop $2
  200. StrCmp $2 "" "" AddToPath_done
  201. Push "$1;"
  202. Push "$3\;"
  203. Call StrStr
  204. Pop $2
  205. StrCmp $2 "" "" AddToPath_done
  206. Call IsNT
  207. Pop $1
  208. StrCmp $1 1 AddToPath_NT
  209. ; Not on NT
  210. StrCpy $1 $WINDIR 2
  211. FileOpen $1 "$1\autoexec.bat" a
  212. FileSeek $1 -1 END
  213. FileReadByte $1 $2
  214. IntCmp $2 26 0 +2 +2 # DOS EOF
  215. FileSeek $1 -1 END # write over EOF
  216. FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
  217. FileClose $1
  218. SetRebootFlag true
  219. Goto AddToPath_done
  220. AddToPath_NT:
  221. StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
  222. ReadRegStr $1 ${NT_current_env} "PATH"
  223. Goto DoTrim
  224. ReadAllKey:
  225. ReadRegStr $1 ${NT_all_env} "PATH"
  226. DoTrim:
  227. StrCmp $1 "" AddToPath_NTdoIt
  228. Push $1
  229. Call Trim
  230. Pop $1
  231. StrCpy $0 "$1;$0"
  232. AddToPath_NTdoIt:
  233. StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey
  234. WriteRegExpandStr ${NT_current_env} "PATH" $0
  235. Goto DoSend
  236. WriteAllKey:
  237. WriteRegExpandStr ${NT_all_env} "PATH" $0
  238. DoSend:
  239. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  240. AddToPath_done:
  241. Pop $3
  242. Pop $2
  243. Pop $1
  244. Pop $0
  245. FunctionEnd
  246. ; RemoveFromPath - Remove a given dir from the path
  247. ; Input: head of the stack
  248. Function un.RemoveFromPath
  249. Exch $0
  250. Push $1
  251. Push $2
  252. Push $3
  253. Push $4
  254. Push $5
  255. Push $6
  256. IntFmt $6 "%c" 26 # DOS EOF
  257. Call un.IsNT
  258. Pop $1
  259. StrCmp $1 1 unRemoveFromPath_NT
  260. ; Not on NT
  261. StrCpy $1 $WINDIR 2
  262. FileOpen $1 "$1\autoexec.bat" r
  263. GetTempFileName $4
  264. FileOpen $2 $4 w
  265. GetFullPathName /SHORT $0 $0
  266. StrCpy $0 "SET PATH=%PATH%;$0"
  267. Goto unRemoveFromPath_dosLoop
  268. unRemoveFromPath_dosLoop:
  269. FileRead $1 $3
  270. StrCpy $5 $3 1 -1 # read last char
  271. StrCmp $5 $6 0 +2 # if DOS EOF
  272. StrCpy $3 $3 -1 # remove DOS EOF so we can compare
  273. StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
  274. StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
  275. StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
  276. StrCmp $3 "" unRemoveFromPath_dosLoopEnd
  277. FileWrite $2 $3
  278. Goto unRemoveFromPath_dosLoop
  279. unRemoveFromPath_dosLoopRemoveLine:
  280. SetRebootFlag true
  281. Goto unRemoveFromPath_dosLoop
  282. unRemoveFromPath_dosLoopEnd:
  283. FileClose $2
  284. FileClose $1
  285. StrCpy $1 $WINDIR 2
  286. Delete "$1\autoexec.bat"
  287. CopyFiles /SILENT $4 "$1\autoexec.bat"
  288. Delete $4
  289. Goto unRemoveFromPath_done
  290. unRemoveFromPath_NT:
  291. StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey
  292. ReadRegStr $1 ${NT_current_env} "PATH"
  293. Goto unDoTrim
  294. unReadAllKey:
  295. ReadRegStr $1 ${NT_all_env} "PATH"
  296. unDoTrim:
  297. StrCpy $5 $1 1 -1 # copy last char
  298. StrCmp $5 ";" +2 # if last char != ;
  299. StrCpy $1 "$1;" # append ;
  300. Push $1
  301. Push "$0;"
  302. Call un.StrStr ; Find `$0;` in $1
  303. Pop $2 ; pos of our dir
  304. StrCmp $2 "" unRemoveFromPath_done
  305. ; else, it is in path
  306. # $0 - path to add
  307. # $1 - path var
  308. StrLen $3 "$0;"
  309. StrLen $4 $2
  310. StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
  311. StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
  312. StrCpy $3 $5$6
  313. StrCpy $5 $3 1 -1 # copy last char
  314. StrCmp $5 ";" 0 +2 # if last char == ;
  315. StrCpy $3 $3 -1 # remove last char
  316. StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey
  317. WriteRegExpandStr ${NT_current_env} "PATH" $3
  318. Goto unDoSend
  319. unWriteAllKey:
  320. WriteRegExpandStr ${NT_all_env} "PATH" $3
  321. unDoSend:
  322. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  323. unRemoveFromPath_done:
  324. Pop $6
  325. Pop $5
  326. Pop $4
  327. Pop $3
  328. Pop $2
  329. Pop $1
  330. Pop $0
  331. FunctionEnd
  332. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  333. ; Uninstall sutff
  334. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  335. ###########################################
  336. # Utility Functions #
  337. ###########################################
  338. ;====================================================
  339. ; IsNT - Returns 1 if the current system is NT, 0
  340. ; otherwise.
  341. ; Output: head of the stack
  342. ;====================================================
  343. ; IsNT
  344. ; no input
  345. ; output, top of the stack = 1 if NT or 0 if not
  346. ;
  347. ; Usage:
  348. ; Call IsNT
  349. ; Pop $R0
  350. ; ($R0 at this point is 1 or 0)
  351. !macro IsNT un
  352. Function ${un}IsNT
  353. Push $0
  354. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  355. StrCmp $0 "" 0 IsNT_yes
  356. ; we are not NT.
  357. Pop $0
  358. Push 0
  359. Return
  360. IsNT_yes:
  361. ; NT!!!
  362. Pop $0
  363. Push 1
  364. FunctionEnd
  365. !macroend
  366. !insertmacro IsNT ""
  367. !insertmacro IsNT "un."
  368. ; StrStr
  369. ; input, top of stack = string to search for
  370. ; top of stack-1 = string to search in
  371. ; output, top of stack (replaces with the portion of the string remaining)
  372. ; modifies no other variables.
  373. ;
  374. ; Usage:
  375. ; Push "this is a long ass string"
  376. ; Push "ass"
  377. ; Call StrStr
  378. ; Pop $R0
  379. ; ($R0 at this point is "ass string")
  380. !macro StrStr un
  381. Function ${un}StrStr
  382. Exch $R1 ; st=haystack,old$R1, $R1=needle
  383. Exch ; st=old$R1,haystack
  384. Exch $R2 ; st=old$R1,old$R2, $R2=haystack
  385. Push $R3
  386. Push $R4
  387. Push $R5
  388. StrLen $R3 $R1
  389. StrCpy $R4 0
  390. ; $R1=needle
  391. ; $R2=haystack
  392. ; $R3=len(needle)
  393. ; $R4=cnt
  394. ; $R5=tmp
  395. loop:
  396. StrCpy $R5 $R2 $R3 $R4
  397. StrCmp $R5 $R1 done
  398. StrCmp $R5 "" done
  399. IntOp $R4 $R4 + 1
  400. Goto loop
  401. done:
  402. StrCpy $R1 $R2 "" $R4
  403. Pop $R5
  404. Pop $R4
  405. Pop $R3
  406. Pop $R2
  407. Exch $R1
  408. FunctionEnd
  409. !macroend
  410. !insertmacro StrStr ""
  411. !insertmacro StrStr "un."
  412. Function Trim ; Added by Pelaca
  413. Exch $R1
  414. Push $R2
  415. Loop:
  416. StrCpy $R2 "$R1" 1 -1
  417. StrCmp "$R2" " " RTrim
  418. StrCmp "$R2" "$\n" RTrim
  419. StrCmp "$R2" "$\r" RTrim
  420. StrCmp "$R2" ";" RTrim
  421. GoTo Done
  422. RTrim:
  423. StrCpy $R1 "$R1" -1
  424. Goto Loop
  425. Done:
  426. Pop $R2
  427. Exch $R1
  428. FunctionEnd
  429. Function ConditionalAddToRegisty
  430. Pop $0
  431. Pop $1
  432. StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
  433. WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)" \
  434. "$1" "$0"
  435. ;MessageBox MB_OK "Set Registry: '$1' to '$0'"
  436. DetailPrint "Set install registry entry: '$1' to '$0'"
  437. ConditionalAddToRegisty_EmptyString:
  438. FunctionEnd
  439. ;--------------------------------
  440. !ifdef CPACK_USES_DOWNLOAD
  441. Function DownloadFile
  442. IfFileExists $INSTDIR\* +2
  443. CreateDirectory $INSTDIR
  444. Pop $0
  445. ; Skip if already downloaded
  446. IfFileExists $INSTDIR\$0 0 +2
  447. Return
  448. StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
  449. try_again:
  450. NSISdl::download "$1/$0" "$INSTDIR\$0"
  451. Pop $1
  452. StrCmp $1 "success" success
  453. StrCmp $1 "Cancelled" cancel
  454. MessageBox MB_OK "Download failed: $1"
  455. cancel:
  456. Return
  457. success:
  458. FunctionEnd
  459. !endif
  460. ;--------------------------------
  461. ; Installation types
  462. @CPACK_NSIS_INSTALLATION_TYPES@
  463. ;--------------------------------
  464. ; Component sections
  465. @CPACK_NSIS_COMPONENT_SECTIONS@
  466. ;--------------------------------
  467. ; Define some macro setting for the gui
  468. @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
  469. @CPACK_NSIS_INSTALLER_ICON_CODE@
  470. @CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
  471. ;--------------------------------
  472. ;Pages
  473. !insertmacro MUI_PAGE_WELCOME
  474. !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
  475. Page custom InstallOptionsPage
  476. !insertmacro MUI_PAGE_DIRECTORY
  477. ;Start Menu Folder Page Configuration
  478. !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
  479. !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
  480. !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
  481. !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
  482. !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\NEWS.txt"
  483. @CPACK_NSIS_PAGE_COMPONENTS@
  484. !insertmacro MUI_PAGE_INSTFILES
  485. !insertmacro MUI_PAGE_FINISH
  486. !insertmacro MUI_UNPAGE_CONFIRM
  487. !insertmacro MUI_UNPAGE_INSTFILES
  488. !insertmacro MUI_UNPAGE_FINISH
  489. ;--------------------------------
  490. ;Languages
  491. !insertmacro MUI_LANGUAGE "English" ;first language is the default language
  492. !insertmacro MUI_LANGUAGE "Albanian"
  493. !insertmacro MUI_LANGUAGE "Arabic"
  494. !insertmacro MUI_LANGUAGE "Basque"
  495. !insertmacro MUI_LANGUAGE "Belarusian"
  496. !insertmacro MUI_LANGUAGE "Bosnian"
  497. !insertmacro MUI_LANGUAGE "Breton"
  498. !insertmacro MUI_LANGUAGE "Bulgarian"
  499. !insertmacro MUI_LANGUAGE "Croatian"
  500. !insertmacro MUI_LANGUAGE "Czech"
  501. !insertmacro MUI_LANGUAGE "Danish"
  502. !insertmacro MUI_LANGUAGE "Dutch"
  503. !insertmacro MUI_LANGUAGE "Estonian"
  504. !insertmacro MUI_LANGUAGE "Farsi"
  505. !insertmacro MUI_LANGUAGE "Finnish"
  506. !insertmacro MUI_LANGUAGE "French"
  507. !insertmacro MUI_LANGUAGE "German"
  508. !insertmacro MUI_LANGUAGE "Greek"
  509. !insertmacro MUI_LANGUAGE "Hebrew"
  510. !insertmacro MUI_LANGUAGE "Hungarian"
  511. !insertmacro MUI_LANGUAGE "Icelandic"
  512. !insertmacro MUI_LANGUAGE "Indonesian"
  513. !insertmacro MUI_LANGUAGE "Irish"
  514. !insertmacro MUI_LANGUAGE "Italian"
  515. !insertmacro MUI_LANGUAGE "Japanese"
  516. !insertmacro MUI_LANGUAGE "Korean"
  517. !insertmacro MUI_LANGUAGE "Kurdish"
  518. !insertmacro MUI_LANGUAGE "Latvian"
  519. !insertmacro MUI_LANGUAGE "Lithuanian"
  520. !insertmacro MUI_LANGUAGE "Luxembourgish"
  521. !insertmacro MUI_LANGUAGE "Macedonian"
  522. !insertmacro MUI_LANGUAGE "Malay"
  523. !insertmacro MUI_LANGUAGE "Mongolian"
  524. !insertmacro MUI_LANGUAGE "Norwegian"
  525. !insertmacro MUI_LANGUAGE "Polish"
  526. !insertmacro MUI_LANGUAGE "Portuguese"
  527. !insertmacro MUI_LANGUAGE "PortugueseBR"
  528. !insertmacro MUI_LANGUAGE "Romanian"
  529. !insertmacro MUI_LANGUAGE "Russian"
  530. !insertmacro MUI_LANGUAGE "Serbian"
  531. !insertmacro MUI_LANGUAGE "SerbianLatin"
  532. !insertmacro MUI_LANGUAGE "SimpChinese"
  533. !insertmacro MUI_LANGUAGE "Slovak"
  534. !insertmacro MUI_LANGUAGE "Slovenian"
  535. !insertmacro MUI_LANGUAGE "Spanish"
  536. !insertmacro MUI_LANGUAGE "Swedish"
  537. !insertmacro MUI_LANGUAGE "Thai"
  538. !insertmacro MUI_LANGUAGE "TradChinese"
  539. !insertmacro MUI_LANGUAGE "Turkish"
  540. !insertmacro MUI_LANGUAGE "Ukrainian"
  541. !insertmacro MUI_LANGUAGE "Welsh"
  542. ;--------------------------------
  543. ;Reserve Files
  544. ;These files should be inserted before other files in the data block
  545. ;Keep these lines before any File command
  546. ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
  547. ReserveFile "NSIS.InstallOptions.ini"
  548. !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
  549. ;--------------------------------
  550. ;Installer Sections
  551. Section "-Core installation"
  552. ;Use the entire tree produced by the INSTALL target. Keep the
  553. ;list of directories here in sync with the RMDir commands below.
  554. SetOutPath "$INSTDIR"
  555. @CPACK_NSIS_FULL_INSTALL@
  556. ;Store installation folder
  557. WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
  558. ;Create uninstaller
  559. WriteUninstaller "$INSTDIR\Uninstall.exe"
  560. Push "DisplayName"
  561. Push "@CPACK_NSIS_DISPLAY_NAME@"
  562. Call ConditionalAddToRegisty
  563. Push "DisplayVersion"
  564. Push "@CPACK_PACKAGE_VERSION@"
  565. Call ConditionalAddToRegisty
  566. Push "Publisher"
  567. Push "@CPACK_PACKAGE_VENDOR@"
  568. Call ConditionalAddToRegisty
  569. Push "UninstallString"
  570. Push "$INSTDIR\Uninstall.exe"
  571. Call ConditionalAddToRegisty
  572. Push "NoRepair"
  573. Push "1"
  574. Call ConditionalAddToRegisty
  575. !ifdef CPACK_NSIS_ADD_REMOVE
  576. ;Create add/remove functionality
  577. Push "ModifyPath"
  578. Push "$INSTDIR\AddRemove.exe"
  579. Call ConditionalAddToRegisty
  580. !else
  581. Push "NoModify"
  582. Push "1"
  583. Call ConditionalAddToRegisty
  584. !endif
  585. ; Optional registration
  586. Push "DisplayIcon"
  587. Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
  588. Call ConditionalAddToRegisty
  589. Push "HelpLink"
  590. Push "@CPACK_NSIS_HELP_LINK@"
  591. Call ConditionalAddToRegisty
  592. Push "URLInfoAbout"
  593. Push "@CPACK_NSIS_URL_INFO_ABOUT@"
  594. Call ConditionalAddToRegisty
  595. Push "Contact"
  596. Push "@CPACK_NSIS_CONTACT@"
  597. Call ConditionalAddToRegisty
  598. !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
  599. !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  600. ;Create shortcuts
  601. CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
  602. @CPACK_NSIS_CREATE_ICONS@
  603. @CPACK_NSIS_CREATE_ICONS_EXTRA@
  604. CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
  605. ;Read a value from an InstallOptions INI file
  606. !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
  607. !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
  608. !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
  609. ; Write special uninstall registry entries
  610. Push "StartMenu"
  611. Push "$STARTMENU_FOLDER"
  612. Call ConditionalAddToRegisty
  613. Push "DoNotAddToPath"
  614. Push "$DO_NOT_ADD_TO_PATH"
  615. Call ConditionalAddToRegisty
  616. Push "AddToPathAllUsers"
  617. Push "$ADD_TO_PATH_ALL_USERS"
  618. Call ConditionalAddToRegisty
  619. Push "AddToPathCurrentUser"
  620. Push "$ADD_TO_PATH_CURRENT_USER"
  621. Call ConditionalAddToRegisty
  622. Push "InstallToDesktop"
  623. Push "$INSTALL_DESKTOP"
  624. Call ConditionalAddToRegisty
  625. !insertmacro MUI_STARTMENU_WRITE_END
  626. @CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
  627. SectionEnd
  628. Section "-Add to path"
  629. Push $INSTDIR\bin
  630. StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
  631. StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
  632. Call AddToPath
  633. doNotAddToPath:
  634. SectionEnd
  635. ;--------------------------------
  636. ; Create custom pages
  637. Function InstallOptionsPage
  638. !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@"
  639. !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
  640. FunctionEnd
  641. ;--------------------------------
  642. ; determine admin versus local install
  643. Function un.onInit
  644. ClearErrors
  645. UserInfo::GetName
  646. IfErrors noLM
  647. Pop $0
  648. UserInfo::GetAccountType
  649. Pop $1
  650. StrCmp $1 "Admin" 0 +3
  651. SetShellVarContext all
  652. ;MessageBox MB_OK 'User "$0" is in the Admin group'
  653. Goto done
  654. StrCmp $1 "Power" 0 +3
  655. SetShellVarContext all
  656. ;MessageBox MB_OK 'User "$0" is in the Power Users group'
  657. Goto done
  658. noLM:
  659. ;Get installation folder from registry if available
  660. done:
  661. ;Disable WoW64 redirection
  662. SetRegView 64
  663. FunctionEnd
  664. ;--- Add/Remove callback functions: ---
  665. !macro SectionList MacroName
  666. ;This macro used to perform operation on multiple sections.
  667. ;List all of your components in following manner here.
  668. @CPACK_NSIS_COMPONENT_SECTION_LIST@
  669. !macroend
  670. Section -FinishComponents
  671. ;Removes unselected components and writes component status to registry
  672. !insertmacro SectionList "FinishSection"
  673. !ifdef CPACK_NSIS_ADD_REMOVE
  674. ; Get the name of the installer executable
  675. System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
  676. StrCpy $R3 $R0
  677. ; Strip off the last 13 characters, to see if we have AddRemove.exe
  678. StrLen $R1 $R0
  679. IntOp $R1 $R0 - 13
  680. StrCpy $R2 $R0 13 $R1
  681. StrCmp $R2 "AddRemove.exe" addremove_installed
  682. ; We're not running AddRemove.exe, so install it
  683. CopyFiles $R3 $INSTDIR\AddRemove.exe
  684. addremove_installed:
  685. !endif
  686. SectionEnd
  687. ;--- End of Add/Remove callback functions ---
  688. ;--------------------------------
  689. ; Component dependencies
  690. Function .onSelChange
  691. !insertmacro SectionList MaybeSelectionChanged
  692. FunctionEnd
  693. ;--------------------------------
  694. ;Uninstaller Section
  695. Section "Uninstall"
  696. ReadRegStr $START_MENU SHCTX \
  697. "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)" "StartMenu"
  698. ;MessageBox MB_OK "Start menu is in: $START_MENU"
  699. ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
  700. "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)" "DoNotAddToPath"
  701. ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
  702. "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)" "AddToPathAllUsers"
  703. ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
  704. "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)" "AddToPathCurrentUser"
  705. ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
  706. ReadRegStr $INSTALL_DESKTOP SHCTX \
  707. "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)" "InstallToDesktop"
  708. ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
  709. @CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
  710. ;Remove files we installed.
  711. ;Keep the list of directories here in sync with the File commands above.
  712. @CPACK_NSIS_DELETE_FILES@
  713. @CPACK_NSIS_DELETE_DIRECTORIES@
  714. !ifdef CPACK_NSIS_ADD_REMOVE
  715. ;Remove the add/remove program
  716. Delete "$INSTDIR\AddRemove.exe"
  717. !endif
  718. ;Remove the uninstaller itself.
  719. Delete "$INSTDIR\Uninstall.exe"
  720. DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@ (x64)"
  721. ;Remove the installation directory if it is empty.
  722. RMDir "$INSTDIR"
  723. ; Remove the registry entries.
  724. DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
  725. ; Removes all optional components
  726. !insertmacro SectionList "RemoveSection"
  727. !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
  728. Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
  729. @CPACK_NSIS_DELETE_ICONS@
  730. @CPACK_NSIS_DELETE_ICONS_EXTRA@
  731. ;Delete empty start menu parent diretories
  732. StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
  733. startMenuDeleteLoop:
  734. ClearErrors
  735. RMDir $MUI_TEMP
  736. GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
  737. IfErrors startMenuDeleteLoopDone
  738. StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
  739. startMenuDeleteLoopDone:
  740. ; If the user changed the shortcut, then untinstall may not work. This should
  741. ; try to fix it.
  742. StrCpy $MUI_TEMP "$START_MENU"
  743. Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
  744. @CPACK_NSIS_DELETE_ICONS_EXTRA@
  745. ;Delete empty start menu parent diretories
  746. StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
  747. secondStartMenuDeleteLoop:
  748. ClearErrors
  749. RMDir $MUI_TEMP
  750. GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
  751. IfErrors secondStartMenuDeleteLoopDone
  752. StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
  753. secondStartMenuDeleteLoopDone:
  754. DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
  755. Push $INSTDIR\bin
  756. StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
  757. Call un.RemoveFromPath
  758. doNotRemoveFromPath:
  759. SectionEnd
  760. ;--------------------------------
  761. ; determine admin versus local install
  762. ; Is install for "AllUsers" or "JustMe"?
  763. ; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
  764. ; This function is used for the very first "custom page" of the installer.
  765. ; This custom page does not show up visibly, but it executes prior to the
  766. ; first visible page and sets up $INSTDIR properly...
  767. ; Choose different default installation folder based on SV_ALLUSERS...
  768. ; "Program Files" for AllUsers, "My Documents" for JustMe...
  769. Function .onInit
  770. ; Reads components status for registry
  771. !insertmacro SectionList "InitSection"
  772. ; check to see if /D has been used to change
  773. ; the install directory by comparing it to the
  774. ; install directory that is expected to be the
  775. ; default
  776. StrCpy $IS_DEFAULT_INSTALLDIR 0
  777. ;StrCmp "$INSTDIR" "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
  778. StrCmp "$INSTDIR" "$PROGRAMFILES64\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
  779. StrCpy $IS_DEFAULT_INSTALLDIR 1
  780. StrCpy $SV_ALLUSERS "JustMe"
  781. ; if default install dir then change the default
  782. ; if it is installed for JustMe
  783. StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
  784. StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
  785. ;Disable WoW64 redirection
  786. SetRegView 64
  787. ClearErrors
  788. UserInfo::GetName
  789. IfErrors noLM
  790. Pop $0
  791. UserInfo::GetAccountType
  792. Pop $1
  793. StrCmp $1 "Admin" 0 +3
  794. SetShellVarContext all
  795. ;MessageBox MB_OK 'User "$0" is in the Admin group'
  796. StrCpy $SV_ALLUSERS "AllUsers"
  797. Goto done
  798. StrCmp $1 "Power" 0 +3
  799. SetShellVarContext all
  800. ;MessageBox MB_OK 'User "$0" is in the Power Users group'
  801. StrCpy $SV_ALLUSERS "AllUsers"
  802. Goto done
  803. noLM:
  804. StrCpy $SV_ALLUSERS "AllUsers"
  805. ;Get installation folder from registry if available
  806. done:
  807. StrCmp $SV_ALLUSERS "AllUsers" 0 +3
  808. StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
  809. ;StrCpy $INSTDIR "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
  810. StrCpy $INSTDIR "$PROGRAMFILES64\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
  811. StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
  812. !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
  813. noOptionsPage:
  814. FunctionEnd