setup.nsi 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. Unicode true
  2. ####################################################################
  3. # Includes
  4. !include nsDialogs.nsh
  5. !include MUI2.nsh
  6. !include x64.nsh
  7. !include LogicLib.nsh
  8. ####################################################################
  9. # File Info
  10. !define APP_NAME "RustDeskServer"
  11. !define PRODUCT_NAME "rustdesk_server"
  12. !define PRODUCT_DESCRIPTION "Installer for ${PRODUCT_NAME}"
  13. !define COPYRIGHT "Copyright © 2021"
  14. !define VERSION "1.1.7"
  15. VIProductVersion "${VERSION}.0"
  16. VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
  17. VIAddVersionKey "ProductVersion" "${VERSION}"
  18. VIAddVersionKey "FileDescription" "${PRODUCT_DESCRIPTION}"
  19. VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
  20. VIAddVersionKey "FileVersion" "${VERSION}"
  21. ####################################################################
  22. # Installer Attributes
  23. Name "${APP_NAME}"
  24. Outfile "${APP_NAME}.Setup.exe"
  25. Caption "Setup - ${APP_NAME}"
  26. BrandingText "${APP_NAME}"
  27. ShowInstDetails show
  28. RequestExecutionLevel admin
  29. SetOverwrite on
  30. InstallDir "$PROGRAMFILES64\${APP_NAME}"
  31. ####################################################################
  32. # Pages
  33. !define MUI_ICON "icons\icon.ico"
  34. !define MUI_ABORTWARNING
  35. !define MUI_LANGDLL_ALLLANGUAGES
  36. !define MUI_FINISHPAGE_SHOWREADME ""
  37. !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Startup Shortcut"
  38. !define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateStartupShortcut
  39. !define MUI_FINISHPAGE_RUN "$INSTDIR\${PRODUCT_NAME}.exe"
  40. !insertmacro MUI_PAGE_DIRECTORY
  41. !insertmacro MUI_PAGE_INSTFILES
  42. !insertmacro MUI_PAGE_FINISH
  43. ####################################################################
  44. # Language
  45. !insertmacro MUI_LANGUAGE "English"
  46. !insertmacro MUI_LANGUAGE "SimpChinese"
  47. ####################################################################
  48. # Sections
  49. Section "Install"
  50. SetShellVarContext all
  51. nsExec::Exec 'sc stop hbbr'
  52. nsExec::Exec 'sc stop hbbs'
  53. nsExec::Exec 'taskkill /F /IM ${PRODUCT_NAME}.exe'
  54. Sleep 500
  55. SetOutPath $INSTDIR
  56. File /r "setup\*.*"
  57. WriteUninstaller $INSTDIR\uninstall.exe
  58. CreateDirectory "$SMPROGRAMS\${APP_NAME}"
  59. CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
  60. CreateShortCut "$SMPROGRAMS\${APP_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
  61. CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
  62. nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=in action=allow program="$INSTDIR\hbbs.exe" enable=yes'
  63. nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=out action=allow program="$INSTDIR\hbbs.exe" enable=yes'
  64. nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=in action=allow program="$INSTDIR\hbbr.exe" enable=yes'
  65. nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=out action=allow program="$INSTDIR\hbbr.exe" enable=yes'
  66. ExecWait 'powershell.exe -NoProfile -windowstyle hidden try { [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 } catch {}; Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -OutFile "$$env:TEMP\MicrosoftEdgeWebview2Setup.exe" ; Start-Process -FilePath "$$env:TEMP\MicrosoftEdgeWebview2Setup.exe" -ArgumentList ($\'/silent$\', $\'/install$\') -Wait'
  67. SectionEnd
  68. Section "Uninstall"
  69. SetShellVarContext all
  70. nsExec::Exec 'sc stop hbbr'
  71. nsExec::Exec 'sc stop hbbs'
  72. nsExec::Exec 'taskkill /F /IM ${PRODUCT_NAME}.exe'
  73. Sleep 500
  74. RMDir /r "$SMPROGRAMS\${APP_NAME}"
  75. Delete "$SMSTARTUP\${APP_NAME}.lnk"
  76. Delete "$DESKTOP\${APP_NAME}.lnk"
  77. nsExec::Exec 'sc delete hbbr'
  78. nsExec::Exec 'sc delete hbbs'
  79. nsExec::Exec 'netsh advfirewall firewall delete rule name="${APP_NAME}"'
  80. RMDir /r "$INSTDIR\bin"
  81. RMDir /r "$INSTDIR\logs"
  82. RMDir /r "$INSTDIR\service"
  83. Delete "$INSTDIR\${PRODUCT_NAME}.exe"
  84. Delete "$INSTDIR\uninstall.exe"
  85. SectionEnd
  86. ####################################################################
  87. # Functions
  88. Function CreateStartupShortcut
  89. CreateShortCut "$SMSTARTUP\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
  90. FunctionEnd