setup.nsi 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 PRODUCT_NAME "RustDesk"
  11. !define PRODUCT_DESCRIPTION "Installer for ${PRODUCT_NAME}"
  12. !define COPYRIGHT "Copyright © 2021"
  13. !define VERSION "1.1.6"
  14. VIProductVersion "${VERSION}.0"
  15. VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
  16. VIAddVersionKey "ProductVersion" "${VERSION}"
  17. VIAddVersionKey "FileDescription" "${PRODUCT_DESCRIPTION}"
  18. VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
  19. VIAddVersionKey "FileVersion" "${VERSION}.0"
  20. ####################################################################
  21. # Installer Attributes
  22. Name "${PRODUCT_NAME}"
  23. Outfile "rustdesk-${VERSION}-setup.exe"
  24. Caption "Setup - ${PRODUCT_NAME}"
  25. BrandingText "${PRODUCT_NAME}"
  26. ShowInstDetails show
  27. RequestExecutionLevel admin
  28. SetOverwrite on
  29. InstallDir "$PROGRAMFILES64\${PRODUCT_NAME}"
  30. ####################################################################
  31. # Pages
  32. !define MUI_ICON "src\tray-icon.ico"
  33. !define MUI_ABORTWARNING
  34. !define MUI_LANGDLL_ALLLANGUAGES
  35. !define MUI_FINISHPAGE_SHOWREADME ""
  36. !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  37. !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
  38. !define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopShortcut
  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. SetOutPath $INSTDIR
  51. # Regkeys
  52. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\${PRODUCT_NAME}.exe"
  53. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME} (x64)"
  54. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${VERSION}"
  55. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" '"$INSTDIR\${PRODUCT_NAME}.exe" --uninstall'
  56. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "InstallLocation" "$INSTDIR"
  57. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "Carriez, Inc."
  58. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "HelpLink" "https://www.rustdesk.com/"
  59. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "URLInfoAbout" "https://www.rustdesk.com/"
  60. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "URLUpdateInfo" "https://www.rustdesk.com/"
  61. nsExec::Exec "taskkill /F /IM ${PRODUCT_NAME}.exe"
  62. Sleep 500 ; Give time for process to be completely killed
  63. File "${PRODUCT_NAME}.exe"
  64. SetShellVarContext all
  65. CreateShortCut "$INSTDIR\Uninstall ${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "--uninstall" "msiexec.exe"
  66. CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
  67. CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
  68. CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall ${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "--uninstall" "msiexec.exe"
  69. CreateShortCut "$SMSTARTUP\${PRODUCT_NAME} Tray.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "--tray"
  70. nsExec::Exec 'sc create ${PRODUCT_NAME} start=auto DisplayName="${PRODUCT_NAME} Service" binPath= "\"$INSTDIR\${PRODUCT_NAME}.exe\" --service"'
  71. nsExec::Exec 'netsh advfirewall firewall add rule name="${PRODUCT_NAME} Service" dir=in action=allow program="$INSTDIR\${PRODUCT_NAME}.exe" enable=yes'
  72. nsExec::Exec 'sc start ${PRODUCT_NAME}'
  73. SectionEnd
  74. ####################################################################
  75. # Functions
  76. Function .onInit
  77. # RustDesk is 64-bit only
  78. ${IfNot} ${RunningX64}
  79. MessageBox MB_ICONSTOP "${PRODUCT_NAME} is 64-bit only!"
  80. Quit
  81. ${EndIf}
  82. ${DisableX64FSRedirection}
  83. SetRegView 64
  84. !insertmacro MUI_LANGDLL_DISPLAY
  85. FunctionEnd
  86. Function CreateDesktopShortcut
  87. CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
  88. FunctionEnd