electron / windows-installer

Build Windows Installers for Electron apps
MIT License
1.58k stars 262 forks source link

Incorrect .ico used for Desktop and Start menu shortcuts #365

Open stephendpmurphy opened 3 years ago

stephendpmurphy commented 3 years ago

Hi all :wave:

I am using Electron Forge (specifically the @electron-forge/maker-squirrel module) to create an installer package for a Win32 architecture. I apologize if this is not the correct place for this issue, but I know "windows-installer" is the underlying module used by Electron Forge which is why I'm here.

I have successfully packaged the application and can install/uninstall it from my machine no problem. However, I have some issues with the Start Menu, Taskbar, and Desktop Shortcut icons.

1.) Executing the app using my npm start (electron-forge start) script

2.) First time installing the application using the packaged "app_setup.exe", followed by the application opening for the first time

3.) nth time executing the app, using the Start Menu or Desktop Shortcut (Not the first time)

Package versions

electron version: 10.1.4 maker-squirrel version: 6.0.0-beta.54

maker-squirrel config

"config": {
            "authors": "Stephen Murphy",
            "description": "Open-Source Cross-Platform Serial Monitor written using Electron and NodeJS",
            "exe": "serial_dev.exe",
            "name": "serial_dev",
            "noMsi": false,
            "setupExe": "serial_dev_setup.exe",
            "title": "Serial Dev",
            "iconUrl": "https://electronassets.s3.us-east-2.amazonaws.com/thunder_32x32.ico"
          }

Install directory

image

SquirrelSetup Contents

2020-11-14 12:23:54> Program: Starting Squirrel Updater: --createShortcut=serial_dev.exe
2020-11-14 12:23:54> ApplyReleasesImpl: About to create shortcuts for serial_dev.exe, rootAppDir C:\Users\steph\AppData\Local\serial_dev
2020-11-14 12:23:54> ApplyReleasesImpl: Creating shortcut for serial_dev.exe => C:\Users\steph\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub, Inc.\serial_dev.lnk
2020-11-14 12:23:54> ApplyReleasesImpl: About to save shortcut: C:\Users\steph\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub, Inc.\serial_dev.lnk (target C:\Users\steph\AppData\Local\serial_dev\serial_dev.exe, workingDir C:\Users\steph\AppData\Local\serial_dev\app-1.2.0, args , toastActivatorCSLID aaddbfbd-e30c-5a55-b3aa-1fc98b148508)
2020-11-14 12:23:54> ApplyReleasesImpl: Creating shortcut for serial_dev.exe => C:\Users\steph\Desktop\serial_dev.lnk
2020-11-14 12:23:54> ApplyReleasesImpl: About to save shortcut: C:\Users\steph\Desktop\serial_dev.lnk (target C:\Users\steph\AppData\Local\serial_dev\serial_dev.exe, workingDir C:\Users\steph\AppData\Local\serial_dev\app-1.2.0, args , toastActivatorCSLID aaddbfbd-e30c-5a55-b3aa-1fc98b148508)
2020-11-14 12:23:54> ApplyReleasesImpl: Examining Pin: Altium Designer.lnk
2020-11-14 12:23:54> ApplyReleasesImpl: Examining Pin: File Explorer.lnk
2020-11-14 12:23:54> ApplyReleasesImpl: Examining Pin: Firefox.lnk
2020-11-14 12:23:54> ApplyReleasesImpl: Examining Pin: Google Chrome.lnk
2020-11-14 12:23:54> ApplyReleasesImpl: Examining Pin: Visual Studio Code.lnk
2020-11-14 12:23:54> ApplyReleasesImpl: Examining Pin: Windows PowerShell (x86).lnk
adabru commented 3 years ago

Did you check the related issue: https://github.com/Squirrel/Squirrel.Windows/issues/761 ? Does your registry value DisplayIcon at HKEY_CURRENT\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\serial_dev show the correct path? You can e.g. check with windows builtin regedit.exe.

I'm currently embedding my icon as https://github.com/Squirrel/Squirrel.Windows/issues/761#issuecomment-380720836 suggests and stumbled across your issue :)

karimayachi commented 3 years ago

I stumbled upon this issue when researching my own issue over at electron-forge: https://github.com/electron-userland/electron-forge/issues/2569

What you describe here seems to be in line with my findings.

That the taskbar-icon shows up in development, but not in the deployed version is probably because you set it through Electron's new BrowserWindow or .setIcon functionality which seems to be broken in production builds (that's what my issue was about).

The edit/adendum section of my issue covers your other findings:

I assume you use mongodb-js/electron-squirrel-startup (implicitly) to create the desktop- and startmenu shortcuts.

Anyway, nothing is setting the icon on the app's executable, so on n-th run the icon doesn't show up in the taskbar. (since also setting it in Electron itself is broken as per my issue).

There are a few ways this would start to work as expected:

  1. electron/windows-installer could use rcedit to insert the iconUrl into the app's executable, the same way it inserts setupIcon into the installers executable
  2. mongodb-js/electron-squirrel-startup could use the uninstall-icon or the iconUrl in the creation of the desktop- and startmenu shortcuts (as in this abandoned PR: mongodb-js/electron-squirrel-startup#10
  3. electron-userland/electron-forge/issues/2569 could be fixed, so that you could at least set the taskbar icon from code (although the shortcuts still wouldn't have the icon)

I don't understand why 1 or 2 or both aren't already implemented this way. It's all a rather confusing situation.

I don't have a solution for you, but I hope this will generate some insights.

stephendpmurphy commented 3 years ago

@karimayachi thanks for at least continuing the discussion and posting your findings. This issue is rather stale and I haven't touched the source in a minute. I had transitioned to creating .msi installers (I had a need to install on corporate networks and this install flow fit better than the Squirrel installer) so I also lost the need to solve this problem.

I'm still interested in finding the solution however since I prefer the seamless Squirrel installer method.

chickahoona commented 1 year ago

I am running into this issue here too. As this is now open for 1.5 years and a "correct start menu icon" seems likly to be affecting everyone who creates windows installers, I was wondering if there is any update to this issue.

Mgrdich commented 1 year ago

it is not working for me as well only on the shortcut level , but in the program files and stuff it is working ,

you might wanna check how to reset icons on windows because it sometimes caches.

https://www.makeuseof.com/windows-rebuild-icon-cache/.

but that does not fix the desktop icon issue.