Search code examples
c#iconswindows-explorersystray

c# problem with systray icons in windows-server


i work with windows server 2003 (and 2008) and C#, i have a problem with systray of the desktop.I have done an application for disk managment and when the application start, it hide itself from taskbar and adds an icon in the systray. When i click on this icon (in the systray) the Form of the application is showed.

I have created a task in the system scheduler to execute automaticaly the application at a specific time, if i'm logged on the server when the application is lunched (from the scheduler), the icon appear in the systray of the desktop. But if i'm not logged on server and the scheduler lunch my application, when i log on i can't see the icon in the systray, but my application working perfectly.

I tryied different ways to show the application form, example, the application read a flag in a file and when the flag is true it forces the form.Show() but don't work.

I suppose i have to notifiead my application form to explorer (process) when the desktop is loaded but i haven't idea how do this. It's corrent way? I'm waiting for yours advice.

Best Regards


Solution

  • I suppose that this is due to the fact that when nobody's logged in, there is no desktop session to run the application in.

    Even though the application may work fine, it is not running under the user that logs in later, so you can't see the icon. It is running as a different user "in the background".

    This is effectively the same as when two users are logged in using Remote Desktop. One can start an application that creates a systray icon, the other user will not see that icon.

    One alternative would be to put the application's logic into a windows service. Then, I'd create a client that auto-runs when a user logs in, checks whether the service is currently active and shows the icon and the form.