Guest User

Untitled

a guest
Apr 23rd, 2021
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.46 KB | None | 0 0
  1. !include "LogicLib.nsh"
  2.  
  3. ;Include Modern UI
  4. !include "MUI2.nsh"
  5. !include "nsDialogs.nsh"
  6. !include "nsDialogs_createTextMultiline.nsh"
  7. !include "StrRep.nsh"
  8. !include "ReplaceInFile.nsh"
  9. !include "Sections.nsh"
  10. !include "winmessages.nsh"
  11.  
  12. !define MAJOR_VERSION "1"
  13. !define MINOR_VERSION "2"
  14. !define PATCH_VERSION "3"
  15. !define BUILD_VERSION "4"
  16.  
  17. !define APP_COPYRIGHT "MyApp © My Company 2021"
  18. !define COMPANY_NAME "MyCompany"
  19. !define LICENSE_APP "MyLicenseApp"
  20. !define FLEX_DIR "LicenseManagerSMyApp"
  21. !define HW_DATA "HW-Data"
  22. !define HW_WORKSPACE "HW-Workspaces"
  23. !define LANG_ENGLSH "English"
  24. !define PRODUCT_NAME "MyApp"
  25. !define PRODUCT_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}.${BUILD_VERSION}"
  26. !define SETUP_NAME "MyAppSetup.exe"
  27.  
  28. BrandingText "${COMPANY_NAME}"
  29.  
  30. OutFile ${SETUP_NAME}
  31. Icon "favicon.ico"
  32. UninstallIcon "favicon.ico"
  33. !define MUI_ICON "favicon.ico"
  34. !define MUI_UNICON "favicon.ico"
  35. Name "${PRODUCT_NAME}"
  36.  
  37. InstallDir "$PROGRAMFILES64\${PRODUCT_NAME}\"
  38. InstallDirRegKey HKLM "Software\$PRODUCT_NAME" ""
  39. ShowInstDetails hide
  40. ShowUnInstDetails hide
  41.  
  42. SetCompressor /SOLID lzma
  43. SetCompressorDictSize 12
  44.  
  45. ;Request application privileges for Windows
  46. RequestExecutionLevel admin
  47.  
  48. ; HKLM (all users) vs HKCU (current user) defines
  49. !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
  50. !define env_hkcu 'HKCU "Environment"'
  51.  
  52. !macro WriteSignedUninstaller Destination
  53. !makensis '"/DGENRATINGUNINST=$%TEMP%\Uninst.exe" "${__FILE__}" "/XOutfile `$%TEMP%\tempinstaller.exe`"' = 0 ; Create fake installer
  54. !system 'set __COMPAT_LAYER=RunAsInvoker&"$%TEMP%\tempinstaller.exe"' = 2 ; Run fake installer to generate the uninstaller
  55. !system 'SIGNTOOL sign /f ../CodeSigningCertificate/MyCompanySolutions.pfx /p MyCertPassword /tr http://timestamp.digicert.com /td SHA256 "$%TEMP%\Uninst.exe"' = 0 ; Change this line. As a demonstration, use !system 'echo Dummy >> "$%TEMP%\Uninst.exe"'
  56. File "/oname=${Destination}" "$%TEMP%\Uninst.exe"
  57. !macroend
  58.  
  59. !macro DeclareLanguages
  60. !insertmacro MUI_LANGUAGE ${LANG_ENGLSH}
  61. !macroend
  62.  
  63. !ifndef GENRATINGUNINST
  64. Var MyPartnerAppInstallDir
  65. Var MyAppInstallDir
  66. Var LicenseManagerLmInstallDir
  67. Var HwDataDir
  68. Var HwWorkspaceDir
  69. Var headwaveConfigDialog
  70. Var headwaveConfigHwnd
  71. Var headwaveConfigDataDirLabel
  72. Var headwaveConfigDataDirText
  73. Var headwaveConfigWkDirLabel
  74. Var headwaveConfigWkDirText
  75. Var userInfoDialog
  76. Var userInfoHwnd
  77.  
  78. # Installer:
  79. ############
  80. !insertmacro MUI_PAGE_WELCOME
  81. !insertmacro MUI_PAGE_LICENSE "MyAppLicense.txt"
  82.  
  83. !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesCheck
  84. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave
  85. !insertmacro MUI_PAGE_COMPONENTS
  86.  
  87.  
  88. ## This is the title on the Headwave/MyPartnerApp installation Directory page to obtain directory for %HEADWAVE_ROOT_DIR%
  89. !define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_HW_INST)"
  90. !define MUI_PAGE_HEADER_TEXT "Choose MyPartnerApp Plugin installation directory"
  91. !define MUI_PAGE_HEADER_SUBTEXT "Select the folder where MyPartnerApp is presently installed to set environment variable."
  92.  
  93. !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesHeadwaveProg
  94. Page custom HeadwaveConfiguration HeadwaveConfigurationLeave
  95. !insertmacro MUI_PAGE_DIRECTORY
  96. !insertmacro MUI_PAGE_INSTFILES
  97.  
  98. ## This is the title on the MyApp Directory page
  99. !define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_A)"
  100. !define MUI_PAGE_HEADER_TEXT "Choose Install Location"
  101. !define MUI_PAGE_HEADER_SUBTEXT "Select the folder in which to install MyApp."
  102.  
  103. !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesMyApp
  104. !insertmacro MUI_PAGE_DIRECTORY
  105. !insertmacro MUI_PAGE_INSTFILES
  106.  
  107. ## This is the title on the MyLicenseApp Directory page
  108. !define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_B)"
  109. !define MUI_PAGE_HEADER_TEXT "Choose Install Location"
  110. !define MUI_PAGE_HEADER_SUBTEXT "Please choose the folder in which to install MyLicenseApp."
  111.  
  112. !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesMyLicenseApp
  113. !insertmacro MUI_PAGE_DIRECTORY
  114. !insertmacro MUI_PAGE_INSTFILES
  115.  
  116. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE DeleteSectionsINI
  117. !define MUI_FINISHPAGE_TEXT "In MyPartnerApp, select File/User preferences:$\n$\nOutput directory = $HwDataDir$\n$\nCompute plugin directories = $HwDataDir\MyApp-Plugins\ComputePlugin$\n$\nExtension plugin directories = $HwDataDir\MyApp-Plugins\ExtensionPlugin$\n$\nThe MyApp to MyPartnerApp connector uses network port 8080 by default. If this is a conflict on your system you can specify a new port by editing both the config.dat and MyAppConfig.py files with a new port number."
  118. !insertmacro MUI_PAGE_FINISH
  119. !insertmacro MUI_UNPAGE_WELCOME
  120. !insertmacro MUI_UNPAGE_CONFIRM
  121. !insertmacro MUI_UNPAGE_INSTFILES
  122. !insertmacro MUI_UNPAGE_FINISH
  123. !insertmacro DeclareLanguages
  124.  
  125. ;--------------------------------
  126.  
  127. LangString NoSectionsSelected ${LANG_ENGLSH} "You haven't selected any sections!"
  128.  
  129. LangString MUI_DIRECTORYPAGE_TEXT_TOP_HW ${LANG_ENGLSH} "Select \
  130. ${HW_DATA} installation location..."
  131. LangString MUI_DIRECTORYPAGE_TEXT_TOP_HW_WK ${LANG_ENGLSH} "Select \
  132. ${HW_WORKSPACE} installation location..."
  133. LangString MUI_DIRECTORYPAGE_TEXT_TOP_HW_INST ${LANG_ENGLSH} "Select \
  134. Headwave installation location..."
  135. LangString MUI_DIRECTORYPAGE_TEXT_TOP_A ${LANG_ENGLSH} "Select \
  136. ${PRODUCT_NAME} installation location..."
  137. LangString MUI_DIRECTORYPAGE_TEXT_TOP_B ${LANG_ENGLSH} "Select \
  138. ${LICENSE_APP} installation location..."
  139.  
  140. ;--------------------------------
  141. ; Settings
  142.  
  143. !define PROG1_InstDir "$PROGRAMFILES64"
  144. !define PROG1_StartIndex ${SEC1}
  145. !define PROG1_EndIndex ${SEC1}
  146.  
  147. !define PROG2_InstDir "$PROGRAMFILES64\${PRODUCT_NAME}"
  148. !define PROG2_StartIndex ${SEC2}
  149. !define PROG2_EndIndex ${SEC2}
  150.  
  151. !define PROG3_InstDir "C:\${FLEX_DIR}"
  152. !define PROG3_StartIndex ${SEC3}
  153. !define PROG3_EndIndex ${SEC3}
  154.  
  155. ;--------------------------------
  156. ; Function
  157. ; StrContains
  158. ; This function does a case sensitive searches for an occurrence of a substring in a string.
  159. ; It returns the substring if it is found.
  160. ; Otherwise it returns null("").
  161. ; Written by kenglish_hi
  162. ; Adapted from StrReplace written by dandaman32
  163.  
  164.  
  165. Var STR_HAYSTACK
  166. Var STR_NEEDLE
  167. Var STR_CONTAINS_VAR_1
  168. Var STR_CONTAINS_VAR_2
  169. Var STR_CONTAINS_VAR_3
  170. Var STR_CONTAINS_VAR_4
  171. Var STR_RETURN_VAR
  172.  
  173. Function StrContains
  174. Exch $STR_NEEDLE
  175. Exch 1
  176. Exch $STR_HAYSTACK
  177. ; Uncomment to debug
  178. ;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
  179. StrCpy $STR_RETURN_VAR ""
  180. StrCpy $STR_CONTAINS_VAR_1 -1
  181. StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
  182. StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
  183. loop:
  184. IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
  185. StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
  186. StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
  187. StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
  188. Goto loop
  189. found:
  190. StrCpy $STR_RETURN_VAR $STR_NEEDLE
  191. Goto done
  192. done:
  193. Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the
  194. Exch $STR_RETURN_VAR
  195. FunctionEnd
  196.  
  197. !macro _StrContainsConstructor OUT NEEDLE HAYSTACK
  198. Push `${HAYSTACK}`
  199. Push `${NEEDLE}`
  200. Call StrContains
  201. Pop `${OUT}`
  202. !macroend
  203.  
  204. !define StrContains '!insertmacro "_StrContainsConstructor"'
  205.  
  206. ;--------------------------------
  207. ; Start sections
  208.  
  209. ## Section 1
  210. Section "Headwave Plugin" SEC1
  211. MessageBox MB_OK 'Headwave Plugin #1: INSTDIR = $INSTDIR'
  212. ${StrContains} $0 "MyPartnerApp" "$INSTDIR"
  213. StrCmp $0 "" notfoundMyPartnerApp
  214. Goto doneMyPartnerApp
  215. doneMyPartnerApp:
  216. MessageBox MB_OK 'Headwave Plugin #2: HwDataDir = $HwDataDir'
  217. SetOutPath "$HwDataDir"
  218. ${StrContains} $0 "Data" "$HwDataDir"
  219. StrCmp $0 "" notfoundHwData
  220. Goto doneHwData
  221. ;MessageBox MB_OK 'Did not find MyApp string'
  222. doneHwData:
  223.  
  224. ##All the files in Group 0 will be installed to the same location, $HwDataDir
  225. MessageBox MB_OK 'Headwave Plugin #3: HwDataDir = $HwDataDir'
  226. SetOutPath "$HwDataDir"
  227. CreateDirectory "$HwDataDir"
  228. CreateDirectory "$HwDataDir\MyApp-Plugins"
  229. CreateDirectory "$HwDataDir\MyApp-Plugins\ComputePlugin"
  230. CreateDirectory "$HwDataDir\MyApp-Plugins\ExtensionPlugin"
  231.  
  232. File /oname=$HwDataDir\MyApp-Plugins\ComputePlugin\computeplugin.xplot.dll computeplugin.xplot.dll
  233. File /oname=$HwDataDir\MyApp-Plugins\ComputePlugin\computeplugin.VirtualVolume.dll computeplugin.VirtualVolume.dll
  234.  
  235. File /oname=$HwDataDir\MyApp-Plugins\ExtensionPlugin\hwProxyInterface.MyApp.dll hwProxyInterface.MyApp.dll
  236.  
  237. # MyPartnerApp workspace
  238. CreateDirectory "$HwWorkspaceDir"
  239.  
  240. ##All the files in Group 1 will be installed to the same location, $INSTDIR
  241. SetOutPath "$INSTDIR"
  242. ;messagebox mb_ok "MyPartnerApp Program: INSTDIR is $INSTDIR"
  243.  
  244. # set environment variable for current user
  245. WriteRegExpandStr ${env_hkcu} HEADWAVE_ROOT_DIR $INSTDIR
  246. # save the selected headwave program directory
  247. StrCpy $MyPartnerAppSelectedInstallDir $INSTDIR
  248. # make sure windows knows about the change
  249. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  250.  
  251. # Install Sound-MyApp python scripts
  252. CreateDirectory $INSTDIR\python\hwtoolkits\MyCompany
  253. File __init__.py
  254. File MyAppConfig.py
  255. File MyAppPlugin.py
  256.  
  257. CopyFiles $INSTDIR\*.py $INSTDIR\python\hwtoolkits\MyCompany
  258.  
  259. notfoundHwData:
  260. notfoundMyPartnerApp:
  261. ; Do nothing
  262. SectionEnd
  263.  
  264.  
  265. ## Sections 2
  266. Section "MyApp" SEC2
  267. ${StrContains} $0 "Pro" "$INSTDIR"
  268. StrCmp $0 "" notfoundMyApp
  269. StrCpy $MyAppInstallDir "$INSTDIR"
  270. Goto doneMyApp
  271. ;MessageBox MB_OK 'Did not find MyApp string'
  272.  
  273. doneMyApp:
  274.  
  275. ##All the files in Group 2 will be installed to the same location, $INSTDIR
  276. SetOutPath "$INSTDIR"
  277.  
  278. !insertmacro WriteSignedUninstaller "$InstDir\Uninst.exe"
  279.  
  280. # specify files to go in output path
  281. File MyApp.exe
  282. File readme.txt
  283. File ReleaseNotes.txt
  284.  
  285. # Create config.dat based on user`s previous selection
  286. IfFileExists "$INSTDIR\config.dat" file_found file_not_found
  287. file_found:
  288. ; Do nothing
  289. goto end_of_test ;<== important for not continuing on the else branch
  290. file_not_found:
  291. nsExec::ExecToStack 'cmd /c "@echo ServerPort = 2003 > config.dat"'
  292. Pop $0 # return value/error/timeout
  293. Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}
  294. DetailPrint 'cmd /c "@echo ServerPort = 2003 > config.dat" printed: $1'
  295. DetailPrint ""
  296. DetailPrint " Return value: $0"
  297. DetailPrint ""
  298. nsExec::ExecToStack 'cmd /c "@echo MyPartnerAppPort = 2004 >> config.dat"'
  299. nsExec::ExecToStack 'cmd /c "@echo MyPartnerAppOutputDirectory = $HwDataDir >> config.dat"'
  300.  
  301. # 2
  302. ; messagebox mb_ok "MyApp Main: HW Data Dir $HwDataDir"
  303. nsExec::ExecToStack 'cmd /c "@echo MyPartnerAppWorkspaceDirectory = $HwWorkspaceDir >> config.dat"'
  304.  
  305. # 3
  306. ; messagebox mb_ok "MyApp Main: HW Workspace Dir $HwWorkspaceDir"
  307. end_of_test:
  308.  
  309. # create a shortcut named "new shortcut" in the start menu programs directory
  310. CreateShortcut "$SMPROGRAMS\${PRODUCT_NAME}.lnk" "$InstDir\${PRODUCT_NAME}.exe"
  311.  
  312. # Add application to registry
  313. ClearErrors
  314. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'Contact' "https://www.mycompany.com/contact"
  315. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'Company Name' "${COMPANY_NAME}"
  316. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'DisplayName' "${PRODUCT_NAME}"
  317. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'DisplayVersion' "${PRODUCT_VERSION}"
  318. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'AppID' "{e2248c93-74ae-4336-9191-1b97a3a17e7e}"
  319. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'HelpLink' "http://www.myapp.com/MyApp/HelpDocs/index.htm"
  320. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'URLInfoAbout' "https://www.mycompany.com/myapp"
  321. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'InstallLocation' "$MyAppInstallDir"
  322. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'Publisher' "${COMPANY_NAME}"
  323.  
  324. # Add program to Add/Remove programs
  325. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  326. "DisplayIcon" "$PROGRAMFILES64\${PRODUCT_NAME}\${PRODUCT_NAME}.exe"
  327. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  328. "AppID" "{e2248c93-74ae-4336-9191-1b97a3a17e7e}"
  329. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  330. "DisplayName" "${PRODUCT_NAME}"
  331. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  332. "DisplayVersion" "${PRODUCT_VERSION}"
  333. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  334. "InstallLocation" "$INSTDIR"
  335. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  336. "Publisher" "${COMPANY_NAME}"
  337. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  338. "UninstallString" "$\"$INSTDIR\Uninst.exe$\""
  339.  
  340. # MyLicenseApp libs
  341. Delete $INSTDIR\SMyApp.exe
  342. Delete $INSTDIR\MyLicenseApp.log
  343. Delete $INSTDIR\installs.exe
  344.  
  345. ; MessageBox MB_OK "SEC2 #3 INSTDIR is $INSTDIR"
  346. StrCmp "$INSTDIR" "$PROGRAMFILES64\${PRODUCT_NAME}" 0 jump_to_if_not_equal
  347. goto end
  348. jump_to_if_not_equal:
  349. Delete $PROGRAMFILES64\${PRODUCT_NAME}\config.dat
  350. Delete $PROGRAMFILES64\${PRODUCT_NAME}\MyApp.exe
  351. Delete $PROGRAMFILES64\${PRODUCT_NAME}\readme.txt
  352. Delete $PROGRAMFILES64\${PRODUCT_NAME}\ReleaseNotes.txt
  353. Delete $PROGRAMFILES64\${PRODUCT_NAME}\Uninst.exe
  354. RMDir $PROGRAMFILES64\${PRODUCT_NAME}
  355. end:
  356. notfoundMyApp:
  357.  
  358. # messagebox mb_ok SEC2
  359. SectionEnd
  360.  
  361. ## Section 3
  362. Section /o "MyLicenseApp" SEC3
  363. ${StrContains} $0 "Pro" "$INSTDIR"
  364. StrCmp $0 "" notfoundMyApp
  365. StrCpy $MyAppInstallDir "$INSTDIR"
  366. Goto doneMyApp
  367. notfoundMyApp:
  368. ;MessageBox MB_OK 'Did not find MyApp string'
  369.  
  370. ${StrContains} $0 "LicenseManager" "$INSTDIR"
  371. StrCmp $0 "" notfoundLicenseManager
  372. StrCpy $LicenseManagerLmInstallDir "$INSTDIR"
  373. Goto doneLicenseManager
  374. notfoundLicenseManager:
  375. ; Do nothing
  376. doneLicenseManager:
  377.  
  378. ##All the files in Group 2 will be installed to the same location, $INSTDIR
  379. SetOutPath "$INSTDIR"
  380.  
  381. # Add application to registry
  382. WriteRegStr HKCU "SOFTWARE\${LICENSE_APP}" 'DisplayName' "${LICENSE_APP}"
  383. WriteRegStr HKCU "SOFTWARE\${LICENSE_APP}" 'InstallLocation' "$INSTDIR"
  384.  
  385. # Files
  386. File MyApp.exe
  387. File MyLicenseApp.log
  388. File installs.exe
  389.  
  390. doneMyApp:
  391.  
  392. SectionEnd
  393.  
  394. ;--------------------------------
  395. ;Descriptions
  396.  
  397. ;Language strings
  398. LangString DESC_SecMyApp ${LANG_ENGLISH} "MyAppTM software is an easy-to-use suite of tools for interactively generating reservoir realizations that are jointly calibrated to all available seismic, petrophysical and production knowledge."
  399. LangString DESC_SecMyLicenseApp ${LANG_ENGLISH} "LicenseManagerSMyApp contains all the files necessary to implement the MyLicenseApp license server."
  400. LangString DESC_SecHeadWave ${LANG_ENGLISH} "MyPartnerApp removes the limitations created by seismic data size to enable full visualization, interactivity, and computation delivering value across the E&P workflow to reduce uncertainty and accelerate time to first oil."
  401.  
  402. ;Assign language strings to sections
  403. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  404. !insertmacro MUI_DESCRIPTION_TEXT ${SEC0MyPartnerApp} $(DESC_SecHeadWave)
  405. !insertmacro MUI_DESCRIPTION_TEXT ${SEC2} $(DESC_SecMyApp)
  406. !insertmacro MUI_DESCRIPTION_TEXT ${SEC2} $(DESC_SecMyLicenseApp)
  407. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  408.  
  409. ;--------------------------------
  410. ; Please don`t modify below here unless you`re a NSIS 'wiz-kid'
  411.  
  412. ## Create $PLUGINSDIR
  413. Function .onInit
  414. InitPluginsDir
  415.  
  416. SetOutPath $TEMP
  417. File /oname=spltmp.bmp "MyApp_LandingPage.bmp"
  418.  
  419. splash::show 2000 $TEMP\spltmp
  420.  
  421. Pop $0 ; $0 has '1' if the user closed the splash screen early,
  422. ; '0' if everything closed normally, and '-1' if some error occurred.
  423.  
  424. Delete $TEMP\spltmp.bmp
  425.  
  426. ; Initialize variables
  427. StrCpy $MyPartnerAppInstallDir ""
  428. FunctionEnd
  429.  
  430. Function .onInstSuccess
  431. Delete $INSTDIR\MyAppConfig.py
  432. Delete $INSTDIR\MyAppPlugin.py
  433. FunctionEnd
  434.  
  435. ## If user goes back to this page from 1st Directory page
  436. ## we need to put the sections back to how they were before
  437. Var IfBack
  438. Function SelectFilesCheck
  439. StrCmp $IfBack 1 0 NoCheck
  440. Call ResetFiles
  441. NoCheck:
  442. FunctionEnd
  443.  
  444. ## Here we are selecting first sections to install
  445. ## by unselecting all the others!
  446. Function SelectFilesMyPartnerAppData
  447. ${If} ${SectionIsSelected} ${SEC1}
  448. ;MessageBox MB_OK "SEC2 #1 INSTDIR is $INSTDIR"
  449. ${Else}
  450. Abort
  451. ${EndIf}
  452.  
  453. # If user clicks Back now, we will know to reselect Group 2`s sections for
  454. # Components page
  455. StrCpy $IfBack 1
  456.  
  457. # We need to save the state of the Group 1 Sections
  458. # for the next InstFiles page
  459. Push $R0
  460. Push $R1
  461.  
  462. StrCpy $R0 ${PROG1_StartIndex} # Group 1 start
  463.  
  464.  
  465.  
  466.  
  467. # Don`t install prog 1?
  468. Call IsPROG1Selected
  469. Pop $R0
  470. StrCmp $R0 1 +4
  471. Pop $R1
  472. Pop $R0
  473. Abort
  474.  
  475. ${If} $MyPartnerAppInstallDir == ""
  476. StrCpy $0 0
  477. loop:
  478. EnumRegKey $1 HKCU "SOFTWARE\MyPartnerAppCompany" $0
  479. StrCmp $1 "" done
  480. IntOp $0 $0 + 1
  481. StrCpy $INSTDIR "$PROGRAMFILES64\$1"
  482. SetOutPath "$INSTDIR"
  483. StrCpy $MyPartnerAppInstallDir $PROGRAMFILES64\$1
  484. Goto loop
  485. done:
  486. ; messagebox mb_ok "MyPartnerAppInstallDir is $MyPartnerAppInstallDir"
  487.  
  488. StrCpy $INSTDIR $MyPartnerAppInstallDir
  489. SetOutPath $INSTDIR
  490. ${Else}
  491. Abort
  492. ${EndIf}
  493.  
  494. # Set current $INSTDIR to PROG1_InstDir define
  495. StrCpy $INSTDIR $MyPartnerAppInstallDir
  496.  
  497. Pop $R1
  498. Pop $R0
  499. FunctionEnd
  500.  
  501. Function SelectFilesMyApp
  502. ${If} ${SectionIsSelected} ${SEC2}
  503. StrCpy $INSTDIR "${PROG2_InstDir}"
  504. ${Else}
  505. Abort
  506. ${EndIf}
  507.  
  508. FunctionEnd
  509.  
  510. ## Here we need to unselect all Group 1 sections
  511. ## and then re-select those in Group 2 (that the user had selected on
  512. ## Components page)
  513. Function SelectFilesMyLicenseApp
  514. ${If} ${SectionIsSelected} ${SEC3}
  515. StrCpy $INSTDIR "${PROG3_InstDir}"
  516. ${Else}
  517. Abort
  518. ${EndIf}
  519.  
  520. FunctionEnd
  521.  
  522. ## Also if no sections are selected, warn the user!
  523. Function ComponentsLeave
  524. Push $R0
  525. Push $R1
  526. Push $R2
  527.  
  528. Call IsPROG1Selected
  529. Pop $R0
  530. Call IsPROG2Selected
  531. Pop $R1
  532. Call IsPROG3Selected
  533. Pop $R2
  534. StrCmp $R0 1 End
  535. StrCmp $R1 1 End
  536. StrCmp $R2 1 End
  537. Pop $R2
  538. Pop $R1
  539. Pop $R0
  540. MessageBox MB_OK|MB_ICONEXCLAMATION "$(NoSectionsSelected)"
  541. Abort
  542.  
  543. End:
  544. Pop $R1
  545. Pop $R0
  546. FunctionEnd
  547.  
  548. Function IsPROG1Selected
  549. Push $R0
  550.  
  551. StrCpy $R0 ${PROG1_StartIndex} # Group 0 HW Data start
  552.  
  553. SectionGetFlags 0 $R0 # Get section flags
  554. IntOp $R0 $R0 & ${SF_SELECTED}
  555. StrCmp $R0 ${SF_SELECTED} 0 +3 # If section is selected, done
  556. StrCpy $R0 1
  557.  
  558. Exch $R0
  559. FunctionEnd
  560.  
  561.  
  562. Function IsPROG2Selected
  563. Push $R0
  564.  
  565. StrCpy $R0 ${PROG2_StartIndex} # Group MyApp start
  566.  
  567. SectionGetFlags 0 $R0 # Get section flags
  568. IntOp $R0 $R0 & ${SF_SELECTED}
  569. StrCmp $R0 ${SF_SELECTED} 0 +3 # If section is selected, done
  570. StrCpy $R0 1
  571.  
  572. Exch $R0
  573. FunctionEnd
  574.  
  575. Function IsPROG3Selected
  576. Push $R0
  577.  
  578. StrCpy $R0 ${PROG3_StartIndex} # Group MyLicenseApp start
  579.  
  580. IntOp $R0 $R0 + 1
  581. SectionGetFlags $R0 $R0 # Get section flags
  582. IntOp $R0 $R0 & ${SF_SELECTED}
  583. StrCmp $R0 ${SF_SELECTED} 0 +3 # If section is selected, done
  584. StrCpy $R0 1
  585.  
  586. Exch $R0
  587. FunctionEnd
  588.  
  589. ## This will set all sections to how they were on the components page
  590. ## originally
  591. Function ResetFiles
  592. Push $R0
  593. Push $R1
  594.  
  595. StrCpy $R0 ${PROG3_StartIndex} # Group 2 start
  596.  
  597. Loop:
  598. IntOp $R0 $R0 + 1
  599. ReadINIStr "$R1" "$PLUGINSDIR\sections.ini" Sections $R0 # Get sec flags
  600. SectionSetFlags $R0 $R1 # Re-set flags for this sec
  601. StrCmp $R0 ${PROG3_EndIndex} 0 Loop
  602.  
  603. Pop $R1
  604. Pop $R0
  605. FunctionEnd
  606.  
  607. ## Here we are deleting the temp INI file at the end of installation
  608. Function DeleteSectionsINI
  609. FlushINI "$PLUGINSDIR\Sections.ini"
  610. Delete "$PLUGINSDIR\Sections.ini"
  611. Delete $INSTDIR\MyApp_LandingPage.bmp
  612. FunctionEnd
  613.  
  614. !else
  615. # Uninstaller:
  616. ##############
  617. !insertmacro MUI_UNPAGE_CONFIRM
  618. !insertmacro MUI_UNPAGE_INSTFILES
  619. !insertmacro DeclareLanguages
  620.  
  621. !verbose push 2
  622. SilentInstall Silent
  623. Section
  624. WriteUninstaller "${GENRATINGUNINST}"
  625. Quit
  626. SectionEnd
  627. !verbose pop
  628.  
  629. Section -Uninstall
  630. # now delete installed files and registry keys for MyApp
  631. ReadRegStr $0 HKCU "SOFTWARE\${COMPANY_NAME}" "InstallLocation"
  632. Delete $0\config.dat
  633. Delete $0\MyApp.exe
  634. Delete $0\readme.txt
  635. Delete $0\ReleaseNotes.txt
  636. Delete $0\MyApp_LandingPage.bmp
  637. Delete $0\MyAppLicense.txt
  638. Delete "$SMPROGRAMS\MyApp.lnk"
  639. DeleteRegKey HKCU "SOFTWARE\${COMPANY_NAME}"
  640. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  641. DeleteRegKey /ifempty HKCU "Software\Modern UI Test"
  642.  
  643. # Delete Seisware libs
  644. Delete $0\libzmq-mt-4_3_0.dll
  645. Delete $0\partnercompany.dll
  646. Delete $0\vcruntime140_1.dll
  647.  
  648. # Final cleanup
  649. Delete "$InstDir\Uninst.exe"
  650. RMDir "$InstDir"
  651. SectionEnd
  652.  
  653. !endif
  654.  
  655.  
Advertisement
Add Comment
Please, Sign In to add comment