felixhao28 / node-systray

A cross-platform systray library for nodejs.
https://www.npmjs.com/package/systray2
MIT License
32 stars 8 forks source link

No icon displayed if node run as service #7

Closed si458 closed 3 years ago

si458 commented 3 years ago

Im having an issue with the systray2 which doesn't display the icon in the taskbar if node is running as a service using winsw or node-windows I get the systray ready message in the windows event logs and also console logs and I can even see the systray exe being run and running too but no icon is ever displayed?

felixhao28 commented 3 years ago

It sounds like an upstream issue. How about trying the binary from https://github.com/getlantern/systray directly as a service? And see if the icon appears?

si458 commented 3 years ago

@felixhao28 im not sure how to build it as an exe? ive tried a few times to no luck 👎

felixhao28 commented 3 years ago

https://github.com/getlantern/systray#try-the-example-app

image

felixhao28 commented 3 years ago

I have an already-built binary but Github won't allow me to put it here.

si458 commented 3 years ago

@felixhao28 ok managed to build the example, however that also doesnt work either as a service, so im guessing its something to do with running tray icons as a service maybe?

felixhao28 commented 3 years ago

I did some google search and it seems like normally Windows services don't have access to GUI because they need to run before the user's logging in. Someone suggests using a separate process to show the tray icon.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/fe24bf89-798e-43e6-a57d-9bda0ca419ff/how-to-make-a-windows-service-that-has-a-task-tray-icon-for-managing-it?forum=csharpgeneral

si458 commented 3 years ago

@felixhao28 thats a bummer/pain altho the node-systray does run the tray.exe seperately? (checked with procexp64.exe) maybe you could run the exe as the currently logged in console user as it currently runs as the service user? EDIT: also opened an issue upstream for you https://github.com/getlantern/systray/issues/210

salamanca2D commented 3 years ago

I compiled mi node app with pkg and then I made an installer with advance installer, that let me execute on startup system (as a service)

si458 commented 3 years ago

@salamanca2D do you have an example as i tried that and never got it work!

si458 commented 3 years ago

I'm closing this as it's already discussed you can't run a tray icon in a windows service So you must create a separate app that runs as a user instead and show the tray icon

ghost commented 2 years ago

https://www.coretechnologies.com/blog/windows-services/interact-with-desktop/