qgroundcontrol_installer.nsi 2.61 KB
Newer Older
1 2
!include "MUI2.nsh"

3
Name "QGroundcontrol"
4
Var StartMenuFolder
5 6 7

InstallDir $PROGRAMFILES\qgroundcontrol

8 9 10 11 12 13 14 15 16 17
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "installheader.bmp";

!insertmacro MUI_PAGE_LICENSE "license.txt"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
18

19
!insertmacro MUI_LANGUAGE "English"
20

21
Section
22
  SetOutPath $INSTDIR
23
  File /r build_windows_install\release\*.*
Don Gagne's avatar
Don Gagne committed
24
  File deploy\px4driver.msi
pixhawk's avatar
pixhawk committed
25
  WriteUninstaller $INSTDIR\QGroundControl_uninstall.exe
26 27
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\QGroundControl" "DisplayName" "QGroundControl"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\QGroundControl" "UninstallString" "$\"$INSTDIR\QGroundControl_uninstall.exe$\""
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

  ; Only attempt to install the PX4 driver if the version isn't present
  !define ROOTKEY "SYSTEM\CurrentControlSet\Control\Class\{4D36E978-E325-11CE-BFC1-08002BE10318}"
  StrCpy $0 0
loop:
  EnumRegKey $1 HKLM ${ROOTKEY} $0
  StrCmp $1 "" notfound cont1

cont1:
  StrCpy     $2 "${ROOTKEY}\$1"
  ReadRegStr $3 HKLM $2 "ProviderName"
  StrCmp     $3 "3D Robotics" found_provider
mismatch:
  IntOp      $0 $0 + 1
  goto  loop

found_provider:
  ReadRegStr $3 HKLM $2 "DriverVersion"
  StrCmp     $3 "2.0.0.4" skip_driver
  goto  mismatch

notfound:
  DetailPrint "USB Driver not found... installing"
Don Gagne's avatar
Don Gagne committed
51
  ExecWait '"msiexec" /i "px4driver.msi"'
52 53 54 55 56
  goto done

skip_driver:
  DetailPrint "USB Driver found... skipping install"
done:
57 58 59
SectionEnd 

Section "Uninstall"
60
  !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
61
  SetShellVarContext all
Don Gagne's avatar
Don Gagne committed
62
  RMDir /r /REBOOTOK $INSTDIR
63
  RMDir /r /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\"
64 65
  SetShellVarContext current
  RMDir /r /REBOOTOK "$APPDATA\QGROUNDCONTROL.ORG\"
66
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\QGroundControl"
67 68 69
SectionEnd

Section "create Start Menu Shortcuts"
70
  SetShellVarContext all
71 72
  CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
  CreateShortCut "$SMPROGRAMS\$StartMenuFolder\QGroundControl.lnk" "$INSTDIR\qgroundcontrol.exe" "" "$INSTDIR\qgroundcontrol.exe" 0
73 74 75 76 77 78 79 80 81 82
SectionEnd

Function .onInit
  ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\QGroundControl" "UninstallString"
  StrCmp $R0 "" done
 
  MessageBox MB_OK|MB_ICONEXCLAMATION \
  	"QGroundControl is already installed. $\n$\nYou must uninstall the previous version before installing a new one."
  Abort
done: 
83
FunctionEnd