Create Beam Cruncher Plus Installer for Windows 10 - crunchtec/Beam-Cruncher-Wiki GitHub Wiki

This wiki page describes how to create a Beam Cruncher Plus installer for Windows 10 with the Nullsoft Scriptable Install System (NSIS).

Prepare Files

To create the installer, gather the following files in a single folder:

BeamCruncherPlus directory, containing all modules needed to run your Python script (including Pyinstaller-generated executable - be sure to thoroughly test this build first!)

LICENSE.txt

readme.txt

crunch_icon.ico (Crunch Tech icon)

pylon_5_Runtime_5.0.12.11830.exe (version may be updated)

Generate Installer Build Script

Download "NSIS" (https://nsis.sourceforge.io/Download) and the "HM NIS Edit software" (http://hmne.sourceforge.net/). Install both.

*Note: Installer scripts (.nsi files) from previous releases are stored on the CrunchFTP server @: \PiCrunchFTP\CrunchFTP\Camera project\Installer Scripts\Beam Cruncher Plus*

Open the "HM NIS Edit" application and select File -> New script from Wizard...

Follow the wizard instructions to auto generate the script file for the basic operations of your installer (i.e. extract files, edit Windows registry, create uninstaller, etc.). Include all of the files listed above (with a directory structure, if desired).

After the basic script has auto generated, add the lines (note the "drivers" folder that I have, in this case, placed the Pylon5 runtime executable into):

  ; Install USB camera drivers from Basler
  DetailPrint "Installing USB camera drivers..."
  ExecWait '"$INSTDIR\drivers\pylon_5_Runtime_5.0.12.11830.exe" /install=USB_Support /quiet'
  DetailPrint "Done."

just below the:

File "drivers\pylon_5_Runtime_5.0.12.11830.exe"

line which unpacks the Pylon5 runtime executable. The "ExecWait" command will install the USB drivers, quietly (i.e. w/o prompting the user).

Then, just before the Uninstall Section add the lines:

Function un.keepUserFilesPrompt
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Would you like to keep your settings files?" IDYES +2
  RMDir /r "$LOCALAPPDATA\CrunchTechnologies\BeamCruncherPlus"
FunctionEnd

which defines a function which prompts the user with "Would you like to keep your settings files?" and deletes the settings files (in AppData/Local) if the user selects "No". Lastly, add the lines:

  ; Provide checkbox to allow user to keep user settings
  call un.keepUserFilesPrompt
  ; Uninstall Basler USB camera drivers
  DetailPrint "Removing USB camera drivers..."
  ExecWait '"$INSTDIR\drivers\pylon_5_Runtime_5.0.12.11830.exe" /uninstall /quiet'
  DetailPrint "Done."

to the beginning of the Uninstall section ("Section Uninstall"), near the bottom of the script.

Lastly, compile and build the installer by right-clicking the name of the script in the "Window list" and select "Compile script". This will leave your compiled installer in the same directory as your .nsi script file.

Be sure to test that the installer is able to find/install Pylon runtime as a separate program or your USB camera drivers will not be installed! Also test that the Pylon runtime application is removed when the uninstaller is run - this ensures that old versions of the driver do not linger if the Beam Cruncher software is uninstalled.

Be sure to place the installer script (.nsi) file you used to generate the installer on the CrunchFTP @:\PiCrunchFTP\CrunchFTP\Camera project\Installer Scripts\Beam Cruncher Plus