Running an exe from windows service that interacts the the user's desktop

﹥>﹥吖頭↗ 提交于 2019-12-12 01:18:39

问题


I've created a windows service in C# and Windows Server 2003. I would like my service to be able to run an exe file that is Windows forms application. When I start the service - it runs the other application but I cannot see it. When I open Task Manager - i can see that the application is running but I just cannot see it. I have checked "Allow the service to interact with the desktop" but nothing happens. Please help. Is it possible to run and exe from within a windows service and see the exe running in widnows server 2003?


回答1:


Showing UI from a Windows service is very problematic because the service may be running on a different desktop from the user (and on Vista/Server 2008 will in fact always run on a different desktop).

The easiest solution is to run the UI not directly from the service but from an application running on the user's desktop (maybe set to run at login) that communicate with the service somehow.

Just remember:

  1. There may be no logged in user
  2. There may be multiple logged in users using fast user switching or remote desktop
  3. The application on the user desktop is running in the user's security context, not the service's


来源:https://stackoverflow.com/questions/177588/running-an-exe-from-windows-service-that-interacts-the-the-users-desktop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!