开发者

Where is my task bar icon for System user?

I have created an app whose only UI is a windows task bar icon. When the app is started directly (e.g. double click it in Windows explorer), it shows task bar icon correctly. I need to make sure this app is always running. For that, I created a windows service in C# which checks every 10 seconds if the app is still running and if not, it will restart it by calling

System.Diagnostics.Process.Start("MyApp.exe");

The process is started as I can see it fr开发者_C百科om the task manager. However, I cannot find task bar icon. One thing I noticed is that it runs under System user name when it is started from Window Service.

How can I make the task bar icon visible when started from Windows Service?


Services don't have access to the same desktop as the user on Vista or Win7. Applications started by other processes by default have the same rights as the app that launched them (they run under the same account). You need to either have your service run under a user account, or use ImpersonateLoggedOnUser (not sure what the .NET version of this function is - hopefully you'll be able to find it with this as a starting point).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜