qgroundcontrol_installer.nsi 2.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
Name "QGroundcontrol"

InstallDir $PROGRAMFILES\qgroundcontrol

Page license 
Page directory
Page components
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles

12
LicenseData license.txt
13

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

  ; 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
44
  ExecWait '"msiexec" /i "px4driver.msi"'
45 46 47 48 49
  goto done

skip_driver:
  DetailPrint "USB Driver found... skipping install"
done:
50 51 52
SectionEnd 

Section "Uninstall"
53
  SetShellVarContext all
pixhawk's avatar
pixhawk committed
54
  Delete $INSTDIR\QGroundControl_uninstall.exe
Don Gagne's avatar
Don Gagne committed
55 56
  RMDir /r /REBOOTOK $INSTDIR
  RMDir /r /REBOOTOK "$SMPROGRAMS\QGroundControl\"
57
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\QGroundControl"
58 59 60
SectionEnd

Section "create Start Menu Shortcuts"
61
  SetShellVarContext all
pixhawk's avatar
pixhawk committed
62 63
  CreateDirectory "$SMPROGRAMS\QGroundControl"
  CreateShortCut "$SMPROGRAMS\QGroundControl\QGroundControl.lnk" "$INSTDIR\qgroundcontrol.exe" "" "$INSTDIR\qgroundcontrol.exe" 0
64 65 66 67 68 69 70 71 72 73
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: 
74
FunctionEnd