3

I wrote a python program that get messages from server and invokes windows notification.

I turned the program into a one file executable using pyinstaller, the program works perfect when running as an app.

when I turned it into a service on windows 10 using nssm.exe, the service still works well(listen & response to the server) but the notifications do not displayed.

I tried to

  • allow service interact with desktop under the service properties > log on.
  • change the registry HKEY_LOCAL_MACHINE>SYSTEM>CurrentControlSet>Control>Windows>NoInteractiveService = 0(False)

Is there anything else I can try to solve this problem?

Edit - the program works great (communication & notification) as a script(.py), and as an executable(.exe), the problem is that the notification do not displayed when the executable is running as a service using nssm.

IlayG01
  • 80
  • 1
  • 7

2 Answers2

1

Windows Services run in the background, on the isolated Session 0. Their GUI elements (tray icons, windows) will not show up on your interactive desktop.

In previous versions of Windows, you could switch to Session 0 to see your application's windows (though not it's tray icon). However, access to Session 0 has been removed in Windows 10.

CoreTech
  • 2,345
  • 2
  • 17
  • 24
  • heard about that, may be the problem. I tried to set my service as user service and not system service, still cant see the notifications, do you know a workaround or something? – IlayG01 Apr 27 '21 at 13:05
  • 1
    Running your service in a user account will make no difference. There is no workaround for what you are trying to achieve. The isolation of Session 0 was introduced to prevent "shatter attacks" -- a serious security problem. – CoreTech Apr 28 '21 at 04:58
0

Try using the python module win10toast or wintoast

Links: -

Here's a related video

Hope it solves your problem!

Broteen Das
  • 386
  • 4
  • 12
  • Thanks for the answer. but its irrelevant. the program works well, connects and listens to a remote server using sockets, the notification done with win10toast-click(with callback functions). when the program running as a script(.py) - everything works fine (communication & notifications) when the program run as an app(.exe) - everything works fine (communication & notifications) when the program run as a service(nssm) - the communication works fine (I can see the ack msg in the remote server, but the notification do not display on the screen) – IlayG01 Apr 26 '21 at 10:07
  • This is because it works on Windows only (wintoast)... When it runs as a service, it does not import dependencies which are available in Windows(10) and thus, it throws an error. Although, I doubt it'll help, buts its worth a try - **Try searching a nssm notification workaround/plugin of win10toast...** Or maybe look for something else then... (Sorry I couldn't help) – Broteen Das Apr 27 '21 at 07:33