Skip to content

syedhassaanahmed/kiosk-demo-electron

Repository files navigation

kiosk-demo-electron

Build status

This repository demonstrates how to package and distribute an Electron App which runs in Kiosk mode on Windows 10. It uses the Windows 10 Shell Launcher as well as set the kiosk user to AutoLogon. Packaging the app as an MSI makes sure we can distribute it to multiple kiosks via an MDM solution e.g Microsoft Intune.

Note: Shell Launcher feature requires Windows 10 Enterprise Edition.

The project is described in-depth in this blog post

Create Installer

Windows

npm run dist will build everything and create the MSI in dist folder.

Linux

Use npm run dist:wine. Script assumes that Wine and dotnet45 (using winetricks) are installed and properly configured. If the full path of any of your electron-packager output files is longer than 128 chars, you'll run into error LGHT0103 : The system cannot find the file. Note: Light.exe has a known issue with MSI validation on Wine so it had to be turned off with -sval flag.

Docker

npm run dist:docker will spin up an instance of this image, execute the above wine script and then copy artifacts back to host's dist folder. Script assumes that Docker daemon is running on host.

Configure

Kiosk parameters are passed to the installer like this:

KioskDemoElectron.msi KIOSK_USERNAME=<kiosk user> KIOSK_PASSWORD=<kiosk password>

All params have a default value as can be seen in product.wxs.

How it works

  • First we package the app using electron-packager
  • Then we harvest binaries produced by electron-packager using WiX's Heat tool.
  • We also copy our PowerShell script into the root of electron-packager output. We could let the harvester take care of PowerShell files as well, but we wanted to explicitly specify them in product.wxs with Custom Actions.
  • Output of harvest tool is heat.wxs which contains a Fragment with list of files. We take that as well as product.wxs and pass it to the Candle tool. Candle is responsible for preprocessing .wxs files and generates compiled .wixobj files.
  • Finally we use the Light tool to generate MSI from .wixobj.
  • PowerShell Scripts are executed from WiX Custom Actions.

Why WiX instead of electron-winstaller (Squirrel.Windows)?

In our case, WiX provides lot of flexibility in terms of configuring the installer;

  • Passing params to the setup
  • Executing elevated PowerShell during install/uninstall events
  • Modifying config files based on setup params

Troubleshoot

MSI logging can be enabled by executing the installer like this:

msiexec /i "setup.msi" /l*v "msi.log" PARAM=VALUE

PowerShell log will be written in C:\Windows\SysWOW64\powershell.log.

Telemetry

The solution uses Application Insights to collect basic telemetry data from the app. To enable it, please create an environment variable named APPINSIGHTS_INSTRUMENTATIONKEY and set it to the Instrumentation Key obtained from Azure portal.