question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[nsis] use custom install/uninstall keys in windows registry

See original GitHub issue
  • Version: 21.2.0
  • Target: Windows

Currently electron-builder only provides the customisation for windows registry installation and uninstall keys via nsis.guid field. if not provided, the GUID is produced automatically based on the appId field.

However I would like to use a product name instead of GUID. That wasn’t a problem until very recently, I used to have nsis.guid assigned to my product name and that worked fine.

Since #4069 got merged, the uninstall key under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Product Name is now being wrapped in curly braces HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{Product Name}.

So not only this is a breaking change, but it also prevents me from abusing the nsis.guid in such manner. Removing the nsis.guid leaves me with the GUID being used for the installation key, i.e HKLM\SOFTWARE\0000-0000-0000-0000 instead of HKLM\SOFTWARE\Product Name.

Based on documentation, that’s fine for uninstall key, but I couldn’t find the same mention for the HKLM\SOFTWARE so I assume in the sake of backward compatibility Microsoft Windows supports both GUIDs or Product names.

Based on a quick survey conducted by my colleagues on a very boring windows machine, we couldn’t find a single software product using GUID instead of Product name under HKLM\SOFTWARE, besides apps built with electron-builder.

Additionally, there is a discrepancy in how GUID is being used since #4069, only uninstall key is wrapped in curly braces:

HKLM\SOFTWARE\0000-0000-0000-0000
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{0000-0000-0000-0000}

We’ve also noticed that some Antivirus products get triggered when they stumble upon a GUID key created under HKLM\SOFTWARE\{GUID}.

Given all of the reasoning above, it would be amazing to be able to use the productName for the HKLM\SOFTWARE entry name. This is a breaking change so there must be a migration path.

Based on the source code, it already seems that there is some sort of sanitisation going on in nsisTarget.ts, so allowing something like options.registryInstallerKey || options.guid || UUID.v5(...) would do it.

https://github.com/electron-userland/electron-builder/blob/ebbd9f796e2d8d5b0720b2b699ba24dc159ee692/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts#L152

Also maybe moving curly braces from here into the NsisTarget.ts itself would be wiser, this way we could customise the UNINSTALL_APP_KEY without being trapped in curly braces:

https://github.com/electron-userland/electron-builder/blob/ebbd9f796e2d8d5b0720b2b699ba24dc159ee692/packages/app-builder-lib/templates/nsis/multiUser.nsh#L9

for instance:

https://github.com/electron-userland/electron-builder/blob/ebbd9f796e2d8d5b0720b2b699ba24dc159ee692/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts#L151

could be:

const guid = '{' + options.guid || UUID.v5(appInfo.id, ELECTRON_BUILDER_NS_UUID) + '}';

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
maximiliancsukcommented, Aug 3, 2020

This is still relevant, please re-open!

(stale bot is one of the worst “features” of github issues, imho. An issue won’t magically be solved by just waiting for a bit)

3reactions
pronebirdcommented, Aug 25, 2020

@develar please re-open this issue. There is no activity on this issue because there is not much to add to it besides that someone has to fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reading and Writing the Registry - NSIS makes it easy
The following script example demonstrates several but not all possible ways to manage windows registry within NSIS.
Read more >
NSIS - electron-builder
Windows requires to use registry keys (e.g. INSTALL/UNINSTALL info). Squirrel.Windows simply uses application name as key. But it is not robust — Google...
Read more >
CSC375 Postimplementation issues
MyInstaller.nsi ; ; This script installs the MySoftWarePackage and uninstaller. ; It will ... Registry key to check for directory (so if you...
Read more >
Using NSIS To Make Installable Java Applications
Creates registry keys for uninstallability from Add/Remove programs in the Windows control panel. Makes the application uninstallable. Look at the script below ...
Read more >
File revisions: browser/installer/windows/nsis/uninstaller.nsi
pushed 2022-08-03 03:42 +0000, Nick Alexander, Nick Alexander - Bug 1774082 - Make installer and uninstaller add/remove Toast Notification to/from registry.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found