Making an Installer

OK now you have a nice signed driver, so lets make a fancy installer so people can just double-click to install

These instructions are pretty much the same as the great tutorial at:

blog.codebender.cc/2016/01/04/create-a-simple-windows-driver-installer-using-nsis/

I installed 3.0b3, the latest version as of this tutorial's writing

Find DPinst

This is the Microsoft driver installation software which came with the WDK you installed earlier.

Go to C:\Program Files (x86)\Windows Kits\10\Redist\DIFx and you can find many versions.

I recommend grabbing

C:\Program Files (x86)\Windows Kits\10\Redist\DIFx\dpinst\MultiLin\x64\dpinst.exe

and putting it in your driver folder, called dpinst-x64.exe

Also grab

C:\Program Files (x86)\Windows Kits\10\Redist\DIFx\dpinst\MultiLin\x86\dpinst.exe

and put that also in your driver folder, called dpinst-x86.exe

 

Create a configuration file!

You can spend a ton of time making super customized installation programs - ours originally was for installing a wide range of drivers, here's the core of it

Download: file
# Adafruit Board Driver NSIS Install Script
# Author: Tony DiCola

# Import some useful functions.
!include WinVer.nsh   # Windows version detection.
!include x64.nsh      # X86/X64 version detection.

# Set attributes that describe the installer.
Icon "Assets\adafruit.ico"
Caption "Adafruit Board Drivers"
Name "Adafruit board drivers"
Outfile "adafruit_cplay.exe"
ManifestSupportedOS "all"
SpaceTexts "none"

# Install driver files to a temporary location (then dpinst will handle the real install).
InstallDir "$TEMP\adafruit_cplay"

# Set properties on the installer exe that will be generated.
VIAddVersionKey /LANG=1033 "ProductName" "Adafruit Circuit Playground Driver"
VIAddVersionKey /LANG=1033 "CompanyName" "Adafruit Industries"
VIAddVersionKey /LANG=1033 "LegalCopyright" "Adafruit Industries"
VIAddVersionKey /LANG=1033 "FileDescription" "Installer for Adafruit Circuit Playground board driver."
VIAddVersionKey /LANG=1033 "FileVersion" "1.0.0"
VIProductVersion "1.0.0.0"
VIFileVersion "1.0.0.0"

# Define variables used in sections.
Var dpinst   # Will hold the path and name of dpinst being used (x86 or x64).

# Components page allows user to pick the drivers to install.
PageEx components
  ComponentText "Check the board drivers below that you would like to install.  Click install to start the installation." \
    "" "Select board drivers to install:"
PageExEnd

# Instfiles page does the actual installation.
Page instfiles


# Sections define the components (drivers) that can be installed.
# The section name is displayed in the component select screen and if selected
# the code in the section will be executed during the install.
# Note that /o before the name makes the section optional and not selected by default.

# This first section is hidden and always selected so it runs first and bootstraps
# the install by copying all the files and dpinst to the temp folder location.
Section
  # Copy all the drivers and dpinst exes to the temp location.
  SetOutPath $INSTDIR
  File /r "Drivers"
  File "dpinst-x64.exe"
  File "dpinst-x86.exe"
  # Set dpinst variable based on the current OS type (x86/x64).
  ${If} ${RunningX64}
    StrCpy $dpinst "$INSTDIR\dpinst-x64.exe"
  ${Else}
    StrCpy $dpinst "$INSTDIR\dpinst-x86.exe"
  ${EndIf}
SectionEnd

Section "Circuit Playground"
  # Use dpisnt to install the driver.
  # Note the following options are specified:
  #  /sw = silent mode, hide the installer but not OS prompts (critical!)
  #  /path = path to directory with driver data
  ExecWait '"$dpinst" /sw /path "$INSTDIR\Drivers\Adafruit_CircuitPlayground"'
SectionEnd

Place this file in the directory with dpinst-x86 and dpinst-x64

In Assets, put an ico file with your logo

Inside Drivers put another folder that contains the actual driver files. E.g. Drivers/CircuitPlayground/circuitplay.inf this way you can expand the installer to install more software & drivers easily

If you'd like you can check out our package for the structure:

Go back to the NSI file, right click and Compile it

Read thru the text to make sure everything was found properly!

You can now test it out - double click to run the installer

Check the Details again, to verify the installer did what its supposed to do

Sign the Installer

OK since you have everything set up its easy to also sign the installer! Go into the directory where you have the generated exe and run

"C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool" sign /v /n "Company Name" /tr http://timestamp.globalsign.com/?signature=sha2 /td sha256 driverinstaller.exe

When the customer double clicks, it will let them know that this is Verified to be from Adafruit Industries!

You can see information about the certificate if you Show Details:

You can also check the exe properties:

This guide was first published on Mar 14, 2016. It was last updated on Mar 14, 2016. This page (Making an Installer) was last updated on Mar 15, 2016.