Pages: [1]   Go Down
Author Topic: I wrote a Windows installer for Arduino  (Read 842 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
God Member
*****
Karma: 0
Posts: 594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a NSIS script, really quick and simple once you figure out how to use them. The Arduino team can compile this script to generate a single installer. I'm hoping the team will try this out.

Code:
!include "MUI2.nsh"

!define MUI_ABORTWARNING

;SetCompressor /SOLID /FINAL lzma

Name "Arduino 0017" ; Installer Name

RequestExecutionLevel highest ; Hope that the user is an admin and can install stuff

OutFile "arduino_0017_installer.exe" ; Installer file name

; Set default installation directory, or look for a previous installation
InstallDir $PROGRAMFILES\arduino
InstallDirRegKey HKCU "Software\arduino" ""

; Order the installation wizard pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

; Order the uninstallation wizard pages
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

; Installer language
!insertmacro MUI_LANGUAGE "English"

Section ;"Required"

      ; Backup the hardware folder since people may have custom files in there (this is for upgrading)
      CreateDirectory $INSTDIR\0017_backup_hardware
      CopyFiles /SILENT $INSTDIR\hardware\*.*  $INSTDIR\0017_backup_hardware

      ; Copy all files
      SetOutPath $INSTDIR      
      File /r arduino-0017\*.*
      
      ; Generate uninstaller, see Uninstall section
      WriteUninstaller $INSTDIR\uninstaller.exe
      
      ; Write information for Windows Add/Remove Software
      WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\arduino" "DisplayName" "Arduino"      
      WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\arduino" "UninstallString" "$\"$INSTDIR\uninstaller.exe$\""      
      WriteRegStr HKCU "Software\arduino" "" $INSTDIR
      
SectionEnd

Section "Desktop Shortcut" SecDesktopShortcut

      SetOutPath $DESKTOP
      CreateShortCut $DESKTOP\Arduino.lnk $INSTDIR\arduino.exe
      
SectionEnd

Section "Start Menu Entry" SecStartMenu

      SetOutPath $STARTMENU\Arduino
      CreateShortCut $STARTMENU\Arduino\Arduino.lnk $INSTDIR\arduino.exe
      CreateShortCut $STARTMENU\Arduino\Uninstall.lnk $INSTDIR\uninstaller.exe
      
SectionEnd

; Describe the sections here
LangString DESC_DesktopShortcut ${LANG_ENGLISH} "A shortcut to Arduino on your desktop"
LangString DESC_StartMenu ${LANG_ENGLISH} "A shortcut to Arduino on in your start menu"

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopShortcut} $(DESC_DesktopShortcut)
!insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(DESC_StartMenu)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Section "Uninstall" ; Uninstaller actions
      
      ; Remove installation completely
      Delete $INSTDIR\*.*
      RMDir /r $INSTDIR

      ; Remove created shortcuts
      Delete $STARTMENU\Arduino\Arduino.lnk
      RMDir /r $STARTMENU\Arduino
      Delete $DESKTOP\Arduino.lnk
      
      ; Remove from Windows's Add/Remove Programs
      DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\arduino"
      
SectionEnd

To compile the installation script, go get http://nsis.sourceforge.net/

By using the LZMA Solid Final compression method, the final installer size was about 47 mb, but I commented that line out just in case you guys don't like LZMA for whatever reason (it's slow during compression so it may not be good during testing, but good for release builds)

The installer will make a back-up of the user's hardware folder during upgrades. There is an uninstaller included and adds an entry to the Add/Remove Programs control panel. Desktop and start menu shortcuts are optional.
« Last Edit: October 20, 2009, 11:55:20 am by frank26080115 » Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds ok, maybe I will use it if you make one for the new IDE when it comes out...

Does it currently keep libraries from the previous install and integrate them into the new one? If not then that would be a good next step...

Mowcius
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the arduino team would have to release this
the script does do a backup of the hardware folder, but only a backup, so that updated libraries are applied, any additional libraries that are not a part of the standard package would not be affected i think
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As it happens, I need an Arduino Windows Installer for a CD I'm producing as part of an educational kit.  Mind if I use a slightly modified version of this script to produce said installer?  It would save me a few hours of writing essentially the same script :-)
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

go for it
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Pages: [1]   Go Up
Jump to: