portable.nsi 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. !include "common.nsh"
  2. !include "extractAppPackage.nsh"
  3. # https://github.com/electron-userland/electron-builder/issues/3972#issuecomment-505171582
  4. CRCCheck off
  5. WindowIcon Off
  6. AutoCloseWindow True
  7. RequestExecutionLevel ${REQUEST_EXECUTION_LEVEL}
  8. Function .onInit
  9. !ifndef SPLASH_IMAGE
  10. SetSilent silent
  11. !endif
  12. !insertmacro check64BitAndSetRegView
  13. FunctionEnd
  14. Function .onGUIInit
  15. InitPluginsDir
  16. !ifdef SPLASH_IMAGE
  17. File /oname=$PLUGINSDIR\splash.bmp "${SPLASH_IMAGE}"
  18. BgImage::SetBg $PLUGINSDIR\splash.bmp
  19. BgImage::Redraw
  20. !endif
  21. FunctionEnd
  22. Section
  23. !ifdef SPLASH_IMAGE
  24. HideWindow
  25. !endif
  26. StrCpy $INSTDIR "$PLUGINSDIR\app"
  27. !ifdef UNPACK_DIR_NAME
  28. StrCpy $INSTDIR "$TEMP\${UNPACK_DIR_NAME}"
  29. !endif
  30. RMDir /r $INSTDIR
  31. SetOutPath $INSTDIR
  32. !ifdef APP_DIR_64
  33. !ifdef APP_DIR_ARM64
  34. !ifdef APP_DIR_32
  35. ${if} ${IsNativeARM64}
  36. File /r "${APP_DIR_ARM64}\*.*"
  37. ${elseif} ${RunningX64}
  38. File /r "${APP_DIR_64}\*.*"
  39. ${else}
  40. File /r "${APP_DIR_32}\*.*"
  41. ${endIf}
  42. !else
  43. ${if} ${IsNativeARM64}
  44. File /r "${APP_DIR_ARM64}\*.*"
  45. ${else}
  46. File /r "${APP_DIR_64}\*.*"
  47. {endIf}
  48. !endif
  49. !else
  50. !ifdef APP_DIR_32
  51. ${if} ${RunningX64}
  52. File /r "${APP_DIR_64}\*.*"
  53. ${else}
  54. File /r "${APP_DIR_32}\*.*"
  55. ${endIf}
  56. !else
  57. File /r "${APP_DIR_64}\*.*"
  58. !endif
  59. !endif
  60. !else
  61. !ifdef APP_DIR_32
  62. File /r "${APP_DIR_32}\*.*"
  63. !else
  64. !insertmacro extractEmbeddedAppPackage
  65. !endif
  66. !endif
  67. System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("PORTABLE_EXECUTABLE_DIR", "$EXEDIR").r0'
  68. System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("PORTABLE_EXECUTABLE_FILE", "$EXEPATH").r0'
  69. System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("PORTABLE_EXECUTABLE_APP_FILENAME", "${APP_FILENAME}").r0'
  70. ${StdUtils.GetAllParameters} $R0 0
  71. !ifdef SPLASH_IMAGE
  72. BgImage::Destroy
  73. !endif
  74. ExecWait "$INSTDIR\${APP_EXECUTABLE_FILENAME} $R0" $0
  75. SetErrorLevel $0
  76. SetOutPath $EXEDIR
  77. RMDir /r $INSTDIR
  78. SectionEnd