electron-builder icon indicating copy to clipboard operation
electron-builder copied to clipboard

NSIS Installer doesn't launch on Windows 11 when perUser is set by default

Open pnedkovp opened this issue 1 year ago • 3 comments

  • Electron-Builder Version: 24.13.3
  • Electron Version: 31.3.1
  • Target: nsis

We have an issue with nsis installer on Windows 11. After the application is build the installer doesn't launch on some machines. We have tried building the application with different attributes and it seems that it has something to do with the perMachine property. These are our production build attributes: "nsis": { "oneClick": false, "allowElevation": true, "perMchine": false, "artifactName": "${productName} ${version}.${ext}" }

If we change to oneClick: true or selectPerMachineByDefault: true then the installer starts successfully but with our current setup (onClick: false, perMachine: false) sometimes it crashes.

The error in the event viewer is this: Faulting module name: System.dll, version: 0.0.0.0, time stamp: 0x5c157efa Exception code: 0xc0000005 Fault offset: 0x00001581 Faulting process id: 0x0xF30 Faulting application start time: 0x0x1DB05CD5454D5C0 Faulting application path: *** Faulting module path: C:\Users***\AppData\Local\Temp\nsmD439.tmp\System.dll Report Id: 0e92fa50-e642-47bd-8aac-4b2d8e89f8f8 Faulting package full name: Faulting package-relative application ID:

pnedkovp avatar Sep 25 '24 07:09 pnedkovp

What sticks out to me is the lack of any name here:

Faulting package full name:
Faulting package-relative application ID:

I found this regarding DEP: https://www.tenforums.com/software-apps/206789-application-stopped-running-i-dont-know-what-else-try-2.html and this regarding the Exception Code: https://answers.microsoft.com/en-us/windows/forum/all/how-do-i-fix-this-exception/33382768-19f5-473f-98a2-07e08194272b

Application Error 0xc0000005 (Access Violation) error is usually caused by your computer not being able to correctly process the files and settings required to run a particular program or installation.

I'm not sure if there's much support I can provide here from a code standpoint though. I'm pretty unfamiliar with windows exceptions.

mmaietta avatar Sep 25 '24 15:09 mmaietta

The reason I turn to you is because the installer fails only with a specific set of attributes and not every time. For me it seems it has something to do with the nsis installer script in the case when the default option is to install for the current user only.

pnedkovp avatar Sep 26 '24 06:09 pnedkovp

I have already tried turning off security features including DEP but it didn't do the trick. I also found similar resources on the exception code but I am using a fresh installation of Windows 11 which was specifically made to test the issue above and it doesn't seem to have anything to do with corrupted memory or system files. The issue appears sporadically and it could be something related to OS settings but we can't seem to find such.

pnedkovp avatar Sep 27 '24 07:09 pnedkovp

Hello again, I managed to find where the problem occurs. It's on this line of the multiUser.nsh - https://github.com/electron-userland/electron-builder/blob/3d8e402f0ff1930de9c009dd78ee6dd8fe9c6133/packages/app-builder-lib/templates/nsis/multiUser.nsh#L30 When we have a fresh installation it goes into the else statement and one of the System:: calls crashes the installer. What I would like to do is to simply set the $INSTDIR to "$LocalAppData\Programs${APP_FILENAME}" I am trying to figure out a way to customise the nsis installer using a custom macro but I cannot seem to figure it out.

pnedkovp avatar Nov 12 '24 08:11 pnedkovp

I managed to resolve the problem by using a before-build script which replaces the multiUser.nsh file with a custom one before build.

pnedkovp avatar Nov 12 '24 13:11 pnedkovp

We also got hit by this issue. The workaround from @pnedkovp works, but would be great to have a real fix.

DrJonki avatar Feb 25 '25 11:02 DrJonki

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Mar 28 '25 00:03 github-actions[bot]

Still a relevant issue.

DrJonki avatar Apr 02 '25 17:04 DrJonki

So I'm not familiar/confident enough to make nsh changes, happy to review a PR for any proposed change(s) though!

mmaietta avatar Apr 10 '25 21:04 mmaietta

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar May 11 '25 00:05 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Jun 11 '25 00:06 github-actions[bot]