Grayson
Grayson

Reputation: 191

tray icon doesnt appear when app is run from process.start

I have a C#/winforms application that runs minimized to the system tray. If I double click the EXE for this app it runs as it is supposed to, I see the process in task manager and the icon appears in the system tray. I also have a windows service which acts as a watchdog for the other app. If the winforms app gets closed the service restarts is using process.start

If the app is started from the service using process.start, firing off the same EXE file the process runs but the tray icon doesnt appear.

Just to be clear the winforms app puts the tray icon in place not the windows service.

Any idea why the app would react differently to a process.start than to a double click?

Edit: I may have partially answered my own question. The service is running as local system. Not sure some run as local system would be able to add an icon to my users system tray in the same manner a double click would. Does this sound like I am on the right track?

Upvotes: 1

Views: 1453

Answers (1)

Thomas Weller
Thomas Weller

Reputation: 59493

Yes, you're on the right track. Services run in a different session (session 0). If they open a window (which is highly discouraged), they are now called "interactive services". In that case, Windows pops up a dialog (see MSDN blog for a screenshot).

Similar things probably happen to the tray icon. Since you don't have a window, you don't get the popup dialog for interactive services, but the tray icon still exists in session 0, so you cannot see it.

If you're on Windows 8, interactive services have been disabled (MSDN) completely.

Upvotes: 3

Related Questions