Guest User

Untitled

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