系统用户的任务栏图标在哪里?
我创建了一个应用程序,其唯一的 UI 是 Windows 任务栏图标。当应用程序直接启动时(例如在Windows资源管理器中双击它),它会正确显示任务栏图标。我需要确保这个应用程序始终运行。为此,我在 C# 中创建了一个 Windows 服务,该服务每 10 秒检查一次应用程序是否仍在运行,如果没有,它将通过调用
System.Diagnostics.Process.Start("MyApp.exe");
进程已启动来重新启动它,正如我从任务管理器中看到的那样。但是,我找不到任务栏图标。我注意到的一件事是,当它从 Window Service 启动时,它在系统用户名下运行。
如何使任务栏图标在从 Windows 服务启动时可见?
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 from 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
服务无法访问与 Vista 或 Win7 上的用户相同的桌面。默认情况下,由其他进程启动的应用程序与启动它们的应用程序具有相同的权限(它们在同一帐户下运行)。您需要让服务在用户帐户下运行,或者使用 ImpersonateLoggedOnUser(不确定此函数的 .NET 版本是什么 - 希望您能够以此为起点找到它)。
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).