john_1726

Untitled

Apr 23rd, 2021 (edited)
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.93 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 Apple#Bl0ss0m! /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 MyPartnerAppSelectedInstallDir # In case there are multiple installations
  66. Var MyAppInstallDir
  67. Var LicenseManagerLmInstallDir
  68. Var HwDataDir
  69. Var HwWorkspaceDir
  70. Var headwaveConfigDialog
  71. Var headwaveConfigHwnd
  72. Var headwaveConfigDataDirLabel
  73. Var headwaveConfigDataDirText
  74. Var headwaveConfigWkDirLabel
  75. Var headwaveConfigWkDirText
  76.  
  77. # Installer:
  78. ############
  79. !insertmacro MUI_PAGE_WELCOME
  80. !insertmacro MUI_PAGE_LICENSE "MyAppLicense.txt"
  81.  
  82. !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesCheck
  83. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave
  84. !insertmacro MUI_PAGE_COMPONENTS
  85.  
  86.  
  87. ## This is the title on the Headwave/MyPartnerApp installation Directory page to obtain directory for %HEADWAVE_ROOT_DIR%
  88. !define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_HW_INST)"
  89. !define MUI_PAGE_HEADER_TEXT "Choose MyPartnerApp Plugin installation directory"
  90. !define MUI_PAGE_HEADER_SUBTEXT "Select the folder where MyPartnerApp is presently installed to set environment variable."
  91.  
  92. !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesHeadwaveProg
  93. Page custom HeadwaveConfiguration HeadwaveConfigurationLeave
  94. !insertmacro MUI_PAGE_DIRECTORY
  95. !insertmacro MUI_PAGE_INSTFILES
  96.  
  97. ## This is the title on the MyApp Directory page
  98. !define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_A)"
  99. !define MUI_PAGE_HEADER_TEXT "Choose Install Location"
  100. !define MUI_PAGE_HEADER_SUBTEXT "Select the folder in which to install MyApp."
  101.  
  102. !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesMyApp
  103. !insertmacro MUI_PAGE_DIRECTORY
  104. !insertmacro MUI_PAGE_INSTFILES
  105.  
  106. ## This is the title on the MyLicenseApp Directory page
  107. !define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_B)"
  108. !define MUI_PAGE_HEADER_TEXT "Choose Install Location"
  109. !define MUI_PAGE_HEADER_SUBTEXT "Please choose the folder in which to install MyLicenseApp."
  110.  
  111. !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesMyLicenseApp
  112. !insertmacro MUI_PAGE_DIRECTORY
  113. !insertmacro MUI_PAGE_INSTFILES
  114.  
  115. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE DeleteSectionsINI
  116. !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$\n"
  117. !insertmacro MUI_PAGE_FINISH
  118. !insertmacro MUI_UNPAGE_WELCOME
  119. !insertmacro MUI_UNPAGE_CONFIRM
  120. !insertmacro MUI_UNPAGE_INSTFILES
  121. !insertmacro MUI_UNPAGE_FINISH
  122. !insertmacro DeclareLanguages
  123.  
  124. ;--------------------------------
  125.  
  126. LangString NoSectionsSelected ${LANG_ENGLSH} "You haven't selected any sections!"
  127.  
  128. LangString MUI_DIRECTORYPAGE_TEXT_TOP_HW ${LANG_ENGLSH} "Select \
  129. ${HW_DATA} installation location..."
  130. LangString MUI_DIRECTORYPAGE_TEXT_TOP_HW_WK ${LANG_ENGLSH} "Select \
  131. ${HW_WORKSPACE} installation location..."
  132. LangString MUI_DIRECTORYPAGE_TEXT_TOP_HW_INST ${LANG_ENGLSH} "Select \
  133. Headwave installation location..."
  134. LangString MUI_DIRECTORYPAGE_TEXT_TOP_A ${LANG_ENGLSH} "Select \
  135. ${PRODUCT_NAME} installation location..."
  136. LangString MUI_DIRECTORYPAGE_TEXT_TOP_B ${LANG_ENGLSH} "Select \
  137. ${LICENSE_APP} installation location..."
  138.  
  139. ;--------------------------------
  140. ; Settings
  141.  
  142. !define PROG1_InstDir "$PROGRAMFILES64"
  143. !define PROG1_StartIndex ${SEC1}
  144. !define PROG1_EndIndex ${SEC1}
  145.  
  146. !define PROG2_InstDir "$PROGRAMFILES64\${PRODUCT_NAME}"
  147. !define PROG2_StartIndex ${SEC2}
  148. !define PROG2_EndIndex ${SEC2}
  149.  
  150. !define PROG3_InstDir "C:\${FLEX_DIR}"
  151. !define PROG3_StartIndex ${SEC3}
  152. !define PROG3_EndIndex ${SEC3}
  153.  
  154. ;--------------------------------
  155. ; Function
  156. ; StrContains
  157. ; This function does a case sensitive searches for an occurrence of a substring in a string.
  158. ; It returns the substring if it is found.
  159. ; Otherwise it returns null("").
  160. ; Written by kenglish_hi
  161. ; Adapted from StrReplace written by dandaman32
  162.  
  163.  
  164. Var STR_HAYSTACK
  165. Var STR_NEEDLE
  166. Var STR_CONTAINS_VAR_1
  167. Var STR_CONTAINS_VAR_2
  168. Var STR_CONTAINS_VAR_3
  169. Var STR_CONTAINS_VAR_4
  170. Var STR_RETURN_VAR
  171.  
  172. Function StrContains
  173. Exch $STR_NEEDLE
  174. Exch 1
  175. Exch $STR_HAYSTACK
  176. ; Uncomment to debug
  177. ;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
  178. StrCpy $STR_RETURN_VAR ""
  179. StrCpy $STR_CONTAINS_VAR_1 -1
  180. StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
  181. StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
  182. loop:
  183. IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
  184. StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
  185. StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
  186. StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
  187. Goto loop
  188. found:
  189. StrCpy $STR_RETURN_VAR $STR_NEEDLE
  190. Goto done
  191. done:
  192. Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the
  193. Exch $STR_RETURN_VAR
  194. FunctionEnd
  195.  
  196. !macro _StrContainsConstructor OUT NEEDLE HAYSTACK
  197. Push `${HAYSTACK}`
  198. Push `${NEEDLE}`
  199. Call StrContains
  200. Pop `${OUT}`
  201. !macroend
  202.  
  203. !define StrContains '!insertmacro "_StrContainsConstructor"'
  204.  
  205. ;--------------------------------
  206. ; Start sections
  207.  
  208. ## Section 1
  209. Section "Headwave Plugin" SEC1
  210. MessageBox MB_OK 'Headwave Plugin #1: INSTDIR = $INSTDIR'
  211. ${StrContains} $0 "MyPartnerApp" "$INSTDIR"
  212. StrCmp $0 "" notfoundMyPartnerApp
  213. Goto doneMyPartnerApp
  214. doneMyPartnerApp:
  215. MessageBox MB_OK 'Headwave Plugin #2: HwDataDir = $HwDataDir'
  216. SetOutPath "$HwDataDir"
  217. ${StrContains} $0 "Data" "$HwDataDir"
  218. StrCmp $0 "" notfoundHwData
  219. Goto doneHwData
  220. ;MessageBox MB_OK 'Did not find MyApp string'
  221. doneHwData:
  222.  
  223. ##All the files in Group 0 will be installed to the same location, $HwDataDir
  224. MessageBox MB_OK 'Headwave Plugin #3: HwDataDir = $HwDataDir'
  225. SetOutPath "$HwDataDir"
  226. CreateDirectory "$HwDataDir"
  227. CreateDirectory "$HwDataDir\MyApp-Plugins"
  228. CreateDirectory "$HwDataDir\MyApp-Plugins\ComputePlugin"
  229. CreateDirectory "$HwDataDir\MyApp-Plugins\ExtensionPlugin"
  230.  
  231. File /oname=$HwDataDir\MyApp-Plugins\ComputePlugin\computeplugin.xplot.dll computeplugin.xplot.dll
  232. File /oname=$HwDataDir\MyApp-Plugins\ComputePlugin\computeplugin.VirtualVolume.dll computeplugin.VirtualVolume.dll
  233.  
  234. File /oname=$HwDataDir\MyApp-Plugins\ExtensionPlugin\hwProxyInterface.MyApp.dll hwProxyInterface.MyApp.dll
  235.  
  236. # MyPartnerApp workspace
  237. CreateDirectory "$HwWorkspaceDir"
  238.  
  239. ##All the files in Group 1 will be installed to the same location, $INSTDIR
  240. SetOutPath "$INSTDIR"
  241. ;messagebox mb_ok "MyPartnerApp Program: INSTDIR is $INSTDIR"
  242.  
  243. # set environment variable for current user
  244. WriteRegExpandStr ${env_hkcu} HEADWAVE_ROOT_DIR $INSTDIR
  245. # save the selected headwave program directory
  246. StrCpy $MyPartnerAppSelectedInstallDir $INSTDIR
  247. # make sure windows knows about the change
  248. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  249.  
  250. # Install Sound-MyApp python scripts
  251. CreateDirectory $INSTDIR\python\hwtoolkits\MyCompany
  252. File __init__.py
  253. File MyAppConfig.py
  254. File MyAppPlugin.py
  255.  
  256. CopyFiles $INSTDIR\*.py $INSTDIR\python\hwtoolkits\MyCompany
  257.  
  258. notfoundHwData:
  259. notfoundMyPartnerApp:
  260. ; Do nothing
  261. SectionEnd
  262.  
  263.  
  264. ## Sections 2
  265. Section "MyApp" SEC2
  266. ${StrContains} $0 "Pro" "$INSTDIR"
  267. StrCmp $0 "" notfoundMyApp
  268. StrCpy $MyAppInstallDir "$INSTDIR"
  269. Goto doneMyApp
  270. ;MessageBox MB_OK 'Did not find MyApp string'
  271.  
  272. doneMyApp:
  273.  
  274. ##All the files in Group 2 will be installed to the same location, $INSTDIR
  275. SetOutPath "$INSTDIR"
  276.  
  277. !insertmacro WriteSignedUninstaller "$InstDir\Uninst.exe"
  278.  
  279. # specify files to go in output path
  280. File MyApp.exe
  281. File readme.txt
  282. File ReleaseNotes.txt
  283.  
  284. # Create config.dat based on user`s previous selection
  285. IfFileExists "$INSTDIR\config.dat" file_found file_not_found
  286. file_found:
  287. ; Do nothing
  288. goto end_of_test ;<== important for not continuing on the else branch
  289. file_not_found:
  290. nsExec::ExecToStack 'cmd /c "@echo ServerPort = 2003 > config.dat"'
  291. Pop $0 # return value/error/timeout
  292. Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}
  293. DetailPrint 'cmd /c "@echo ServerPort = 2003 > config.dat" printed: $1'
  294. DetailPrint ""
  295. DetailPrint " Return value: $0"
  296. DetailPrint ""
  297. nsExec::ExecToStack 'cmd /c "@echo MyPartnerAppPort = 2004 >> config.dat"'
  298. nsExec::ExecToStack 'cmd /c "@echo MyPartnerAppOutputDirectory = $HwDataDir >> config.dat"'
  299.  
  300. # 2
  301. ; messagebox mb_ok "MyApp Main: HW Data Dir $HwDataDir"
  302. nsExec::ExecToStack 'cmd /c "@echo MyPartnerAppWorkspaceDirectory = $HwWorkspaceDir >> config.dat"'
  303.  
  304. # 3
  305. ; messagebox mb_ok "MyApp Main: HW Workspace Dir $HwWorkspaceDir"
  306. end_of_test:
  307.  
  308. # create a shortcut named "new shortcut" in the start menu programs directory
  309. CreateShortcut "$SMPROGRAMS\${PRODUCT_NAME}.lnk" "$InstDir\${PRODUCT_NAME}.exe"
  310.  
  311. # Add application to registry
  312. ClearErrors
  313. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'Contact' "https://www.mycompany.com/contact"
  314. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'Company Name' "${COMPANY_NAME}"
  315. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'DisplayName' "${PRODUCT_NAME}"
  316. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'DisplayVersion' "${PRODUCT_VERSION}"
  317. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'AppID' "{e2248c93-74ae-4336-9191-1b97a3a17e7e}"
  318. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'HelpLink' "http://www.myapp.com/MyApp/HelpDocs/index.htm"
  319. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'URLInfoAbout' "https://www.mycompany.com/myapp"
  320. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'InstallLocation' "$MyAppInstallDir"
  321. WriteRegStr HKCU "SOFTWARE\${COMPANY_NAME}" 'Publisher' "${COMPANY_NAME}"
  322.  
  323. # Add program to Add/Remove programs
  324. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  325. "DisplayIcon" "$PROGRAMFILES64\${PRODUCT_NAME}\${PRODUCT_NAME}.exe"
  326. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  327. "AppID" "{e2248c93-74ae-4336-9191-1b97a3a17e7e}"
  328. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  329. "DisplayName" "${PRODUCT_NAME}"
  330. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  331. "DisplayVersion" "${PRODUCT_VERSION}"
  332. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  333. "InstallLocation" "$INSTDIR"
  334. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  335. "Publisher" "${COMPANY_NAME}"
  336. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
  337. "UninstallString" "$\"$INSTDIR\Uninst.exe$\""
  338.  
  339. # MyLicenseApp libs
  340. Delete $INSTDIR\SMyApp.exe
  341. Delete $INSTDIR\MyLicenseApp.log
  342. Delete $INSTDIR\installs.exe
  343.  
  344. ; MessageBox MB_OK "SEC2 #3 INSTDIR is $INSTDIR"
  345. StrCmp "$INSTDIR" "$PROGRAMFILES64\${PRODUCT_NAME}" 0 jump_to_if_not_equal
  346. goto end
  347. jump_to_if_not_equal:
  348. Delete $PROGRAMFILES64\${PRODUCT_NAME}\config.dat
  349. Delete $PROGRAMFILES64\${PRODUCT_NAME}\MyApp.exe
  350. Delete $PROGRAMFILES64\${PRODUCT_NAME}\readme.txt
  351. Delete $PROGRAMFILES64\${PRODUCT_NAME}\ReleaseNotes.txt
  352. Delete $PROGRAMFILES64\${PRODUCT_NAME}\Uninst.exe
  353. RMDir $PROGRAMFILES64\${PRODUCT_NAME}
  354. end:
  355. notfoundMyApp:
  356.  
  357. # messagebox mb_ok SEC2
  358. SectionEnd
  359.  
  360. ## Section 3
  361. Section /o "MyLicenseApp" SEC3
  362. ${StrContains} $0 "Pro" "$INSTDIR"
  363. StrCmp $0 "" notfoundMyApp
  364. StrCpy $MyAppInstallDir "$INSTDIR"
  365. Goto doneMyApp
  366. notfoundMyApp:
  367. ;MessageBox MB_OK 'Did not find MyApp string'
  368.  
  369. ${StrContains} $0 "LicenseManager" "$INSTDIR"
  370. StrCmp $0 "" notfoundLicenseManager
  371. StrCpy $LicenseManagerLmInstallDir "$INSTDIR"
  372. Goto doneLicenseManager
  373. notfoundLicenseManager:
  374. ; Do nothing
  375. doneLicenseManager:
  376.  
  377. ##All the files in Group 2 will be installed to the same location, $INSTDIR
  378. SetOutPath "$INSTDIR"
  379.  
  380. # Add application to registry
  381. WriteRegStr HKCU "SOFTWARE\${LICENSE_APP}" 'DisplayName' "${LICENSE_APP}"
  382. WriteRegStr HKCU "SOFTWARE\${LICENSE_APP}" 'InstallLocation' "$INSTDIR"
  383.  
  384. # Files
  385. File MyApp.exe
  386. File MyLicenseApp.log
  387. File installs.exe
  388.  
  389. doneMyApp:
  390.  
  391. SectionEnd
  392.  
  393. ;--------------------------------
  394. ;Descriptions
  395.  
  396. ;Language strings
  397. 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."
  398. LangString DESC_SecMyLicenseApp ${LANG_ENGLISH} "LicenseManagerSMyApp contains all the files necessary to implement the MyLicenseApp license server."
  399. 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."
  400.  
  401. ;Assign language strings to sections
  402. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  403. !insertmacro MUI_DESCRIPTION_TEXT ${SEC1} $(DESC_SecHeadWave)
  404. !insertmacro MUI_DESCRIPTION_TEXT ${SEC2} $(DESC_SecMyApp)
  405. !insertmacro MUI_DESCRIPTION_TEXT ${SEC2} $(DESC_SecMyLicenseApp)
  406. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  407.  
  408. ;--------------------------------
  409. ; Please don`t modify below here unless you`re a NSIS 'wiz-kid'
  410.  
  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. Function HeadwaveConfiguration
  445. !insertmacro MUI_HEADER_TEXT "Headwave configuration" "Select the respective folders for Headwave."
  446. nsDialogs::Create 1018
  447. Pop $headwaveConfigDialog
  448.  
  449. ${NSD_CreateLabel} 0 0 100% 12u "Select the folder which Headwave can use as a data storage:"
  450. Pop $headwaveConfigDataDirLabel
  451.  
  452. ${NSD_CreateText} 10% 20u 80% 12u "C:\HW-Data"
  453. Pop $headwaveConfigDataDirText
  454.  
  455. ${NSD_CreateLabel} 0 40u 80% 12u "Select the folder which Headwave can use as a workspace:"
  456. Pop $headwaveConfigWkDirLabel
  457.  
  458. ${NSD_CreateText} 10% 60u 80% 12u "C:\HW-Workspaces"
  459. Pop $headwaveConfigWkDirText
  460.  
  461. ;${NSD_CreateLabel} 0 80u 80% 12u "Select the folder where Headwave is installed:"
  462. ;Pop $headwaveConfigProgramDirLabel
  463.  
  464. ;StrCpy $headwaveConfigProgramDirText $MyPartnerAppInstallDir
  465. ;${NSD_CreateText} 10% 100u 80% 12u $MyPartnerAppInstallDir
  466. ;Pop $headwaveConfigProgramDirText
  467.  
  468. SetCtlColors $headwaveConfigHwnd 0xFF0000 0xFFFFFF
  469.  
  470. nsDialogs::Show
  471. FunctionEnd
  472.  
  473. Function HeadwaveConfigurationLeave
  474. ${NSD_GetText} $headwaveConfigDataDirText $0
  475. ;MessageBox MB_OK "HeadwaveConfigurationLeave headwaveConfigDataDirText = $\n$\n$0"
  476. ;StrCpy $HwDataDir $headwaveConfigDataDirText
  477. MessageBox MB_OK "HeadwaveConfigurationLeave HwDataDir = $\n$\n$0"
  478. ${NSD_GetText} $headwaveConfigWkDirText $0
  479. ;MessageBox MB_OK "HeadwaveConfigurationLeave headwaveConfigWkDirText = $\n$\n$0"
  480. ;StrCpy $HwWorkspaceDir $headwaveConfigWkDirText
  481. MessageBox MB_OK "HeadwaveConfigurationLeave HwWorkspaceDir = $\n$\n$0"
  482. FunctionEnd
  483.  
  484. ## Here we are selecting first sections to install
  485. ## by unselecting all the others!
  486. Function SelectFilesHeadwaveProg
  487. ${If} ${SectionIsSelected} ${SEC1}
  488. ;MessageBox MB_OK "SEC2 #1 INSTDIR is $INSTDIR"
  489. ${Else}
  490. Abort
  491. ${EndIf}
  492.  
  493. # If user clicks Back now, we will know to reselect Group 2`s sections for
  494. # Components page
  495. StrCpy $IfBack 1
  496.  
  497. # We need to save the state of the Group 1 Sections
  498. # for the next InstFiles page
  499. Push $R0
  500. Push $R1
  501.  
  502. StrCpy $R0 ${PROG1_StartIndex} # Group 1 start
  503.  
  504. # Don`t install prog 1?
  505. Call IsPROG1Selected
  506. Pop $R0
  507. StrCmp $R0 1 +4
  508. Pop $R1
  509. Pop $R0
  510. Abort
  511.  
  512. ${If} $MyPartnerAppInstallDir == ""
  513. StrCpy $0 0
  514. loop:
  515. EnumRegKey $1 HKCU "SOFTWARE\Bluware" $0
  516. StrCmp $1 "" done
  517. IntOp $0 $0 + 1
  518. StrCpy $INSTDIR "$PROGRAMFILES64\$1"
  519. SetOutPath "$INSTDIR"
  520. StrCpy $MyPartnerAppInstallDir $PROGRAMFILES64\$1
  521. Goto loop
  522. done:
  523. ; messagebox mb_ok "HeadwaveInstallDir is $MyPartnerAppInstallDir"
  524.  
  525. StrCpy $INSTDIR $MyPartnerAppInstallDir
  526. SetOutPath $INSTDIR
  527. ${Else}
  528. Abort
  529. ${EndIf}
  530.  
  531. # Set current $INSTDIR to PROG1_InstDir define
  532. StrCpy $INSTDIR $MyPartnerAppInstallDir
  533. MessageBox MB_OK 'SelectFilesHeadwaveProg: HeadwaveInstallDir = $MyPartnerAppInstallDir'
  534.  
  535. Pop $R1
  536. Pop $R0
  537. FunctionEnd
  538.  
  539. Function SelectFilesMyApp
  540. ${If} ${SectionIsSelected} ${SEC2}
  541. StrCpy $INSTDIR "${PROG2_InstDir}"
  542. ${Else}
  543. Abort
  544. ${EndIf}
  545.  
  546. FunctionEnd
  547.  
  548. ## Here we need to unselect all Group 1 sections
  549. ## and then re-select those in Group 2 (that the user had selected on
  550. ## Components page)
  551. Function SelectFilesMyLicenseApp
  552. ${If} ${SectionIsSelected} ${SEC3}
  553. StrCpy $INSTDIR "${PROG3_InstDir}"
  554. ${Else}
  555. Abort
  556. ${EndIf}
  557.  
  558. FunctionEnd
  559.  
  560. ## Also if no sections are selected, warn the user!
  561. Function ComponentsLeave
  562. Push $R0
  563. Push $R1
  564. Push $R2
  565.  
  566. Call IsPROG1Selected
  567. Pop $R0
  568. Call IsPROG2Selected
  569. Pop $R1
  570. Call IsPROG3Selected
  571. Pop $R2
  572. StrCmp $R0 1 End
  573. StrCmp $R1 1 End
  574. StrCmp $R2 1 End
  575. Pop $R2
  576. Pop $R1
  577. Pop $R0
  578. MessageBox MB_OK|MB_ICONEXCLAMATION "$(NoSectionsSelected)"
  579. Abort
  580.  
  581. End:
  582. Pop $R1
  583. Pop $R0
  584. FunctionEnd
  585.  
  586. Function IsPROG1Selected
  587. Push $R0
  588.  
  589. StrCpy $R0 ${PROG1_StartIndex} # Group 0 HW Data start
  590.  
  591. SectionGetFlags 0 $R0 # Get section flags
  592. IntOp $R0 $R0 & ${SF_SELECTED}
  593. StrCmp $R0 ${SF_SELECTED} 0 +3 # If section is selected, done
  594. StrCpy $R0 1
  595.  
  596. Exch $R0
  597. FunctionEnd
  598.  
  599.  
  600. Function IsPROG2Selected
  601. Push $R0
  602.  
  603. StrCpy $R0 ${PROG2_StartIndex} # Group MyApp start
  604.  
  605. SectionGetFlags 0 $R0 # Get section flags
  606. IntOp $R0 $R0 & ${SF_SELECTED}
  607. StrCmp $R0 ${SF_SELECTED} 0 +3 # If section is selected, done
  608. StrCpy $R0 1
  609.  
  610. Exch $R0
  611. FunctionEnd
  612.  
  613. Function IsPROG3Selected
  614. Push $R0
  615.  
  616. StrCpy $R0 ${PROG3_StartIndex} # Group MyLicenseApp start
  617.  
  618. IntOp $R0 $R0 + 1
  619. SectionGetFlags $R0 $R0 # Get section flags
  620. IntOp $R0 $R0 & ${SF_SELECTED}
  621. StrCmp $R0 ${SF_SELECTED} 0 +3 # If section is selected, done
  622. StrCpy $R0 1
  623.  
  624. Exch $R0
  625. FunctionEnd
  626.  
  627. ## This will set all sections to how they were on the components page
  628. ## originally
  629. Function ResetFiles
  630. Push $R0
  631. Push $R1
  632.  
  633. StrCpy $R0 ${PROG3_StartIndex} # Group 2 start
  634.  
  635. Loop:
  636. IntOp $R0 $R0 + 1
  637. ReadINIStr "$R1" "$PLUGINSDIR\sections.ini" Sections $R0 # Get sec flags
  638. SectionSetFlags $R0 $R1 # Re-set flags for this sec
  639. StrCmp $R0 ${PROG3_EndIndex} 0 Loop
  640.  
  641. Pop $R1
  642. Pop $R0
  643. FunctionEnd
  644.  
  645. ## Here we are deleting the temp INI file at the end of installation
  646. Function DeleteSectionsINI
  647. FlushINI "$PLUGINSDIR\Sections.ini"
  648. Delete "$PLUGINSDIR\Sections.ini"
  649. Delete $INSTDIR\MyApp_LandingPage.bmp
  650. FunctionEnd
  651.  
  652. !else
  653. # Uninstaller:
  654. ##############
  655. !insertmacro MUI_UNPAGE_CONFIRM
  656. !insertmacro MUI_UNPAGE_INSTFILES
  657. !insertmacro DeclareLanguages
  658.  
  659. !verbose push 2
  660. SilentInstall Silent
  661. Section
  662. WriteUninstaller "${GENRATINGUNINST}"
  663. Quit
  664. SectionEnd
  665. !verbose pop
  666.  
  667. Section -Uninstall
  668. # now delete installed files and registry keys for MyApp
  669. ReadRegStr $0 HKCU "SOFTWARE\${COMPANY_NAME}" "InstallLocation"
  670. Delete $0\config.dat
  671. Delete $0\MyApp.exe
  672. Delete $0\readme.txt
  673. Delete $0\ReleaseNotes.txt
  674. Delete $0\MyApp_LandingPage.bmp
  675. Delete $0\MyAppLicense.txt
  676. Delete "$SMPROGRAMS\MyApp.lnk"
  677. DeleteRegKey HKCU "SOFTWARE\${COMPANY_NAME}"
  678. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
  679. DeleteRegKey /ifempty HKCU "Software\Modern UI Test"
  680.  
  681. # Delete Seisware libs
  682. Delete $0\libzmq-mt-4_3_0.dll
  683. Delete $0\partnercompany.dll
  684. Delete $0\vcruntime140_1.dll
  685.  
  686. # Final cleanup
  687. Delete "$InstDir\Uninst.exe"
  688. RMDir "$InstDir"
  689. SectionEnd
  690.  
  691. !endif
  692.  
  693.  
  694.  
  695.  
Add Comment
Please, Sign In to add comment