从与用户桌面交互的 Windows 服务运行 exe [英] Running an exe from windows service that interacts the the user's desktop

查看:53
本文介绍了从与用户桌面交互的 Windows 服务运行 exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C# 和 Windows Server 2003 中创建了一个 Windows 服务.我希望我的服务能够运行作为 Windows 窗体应用程序的 exe 文件.当我启动服务时 - 它运行另一个应用程序,但我看不到它.当我打开任务管理器时 - 我可以看到应用程序正在运行,但我看不到它.我已经勾选了允许服务与桌面交互",但没有任何反应.请帮忙.是否可以从 Windows 服务中运行和 exe 并查看在 widnows server 2003 中运行的 exe?

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?

推荐答案

显示来自 Windows 服务的 UI 非常有问题,因为该服务可能与用户在不同的桌面上运行(并且在 Vista/Server 2008 上实际上总是在不同的桌面上运行).

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).

最简单的解决方案是不直接从服务运行 UI,而是从用户桌面上运行的应用程序(可能设置为在登录时运行)运行 UI,该应用程序以某种方式与服务通信.

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.

记住:

  1. 可能没有登录用户
  2. 可能有多个登录用户使用快速用户切换或远程桌面
  3. 用户桌面上的应用程序在用户的安全上下文中运行,而不是服务的

这篇关于从与用户桌面交互的 Windows 服务运行 exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆