从可以与用户交互的 SYSTEM 身份运行的服务启动应用程序 [英] Starting application from service running as SYSTEM that can interact with the user

查看:22
本文介绍了从可以与用户交互的 SYSTEM 身份运行的服务启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个应用程序需要从我在 .net 3.5 中编码的 Windows 服务启动.此应用程序当前以运行服务的用户身份运行,在我的情况下为 SYSTEM 用户.如果以 SYSTEM 用户身份运行,它不会向用户桌面显示应用程序.想法?建议?

I currently have a single application that needs to be started from a windows service that i am coding in .net 3.5. This application is currently running as the user who ran the service, in my case the SYSTEM user. If running as the SYSTEM user it does not show the application to the users desktop. Thoughts? advice?

//constructor
    private Process ETCHNotify = new Process();

//StartService()     
    ETCHNotify.StartInfo.FileName = baseDir + "\EtchNotify.exe";
    ETCHNotify.StartInfo.UseShellExecute = false;

//BackgroundWorkerThread_DoWork()
    if (!systemData.GetUserName().Equals(""))
    {
        // start ETCHNotify
        try {
            ETCHNotify.Start();
        }
            catch (Exception ex)
        {
            systemData.Run("ERR: Notify can't start: " + ex.Message);
        }
    }

如果我编写的函数 GetUserName()(确定运行 explorer.exe 的用户的用户名)不为空,我只执行 try/catch

I only execute the try/catch if the function i have written GetUserName() (which determines the username of the user running explorer.exe) is not null

再次重申:所需的功能是启动 ETCHNotify 的状态,允许它与 GetUserName() 确定的当前登录用户进行交互

again to reiterate: desired functionality is that this starts ETCHNotify in a state that allows it to interact with the currently logged in user as determined by GetUserName()

推荐答案

最终为了解决这个问题,我听取了@marco 的建议和他提到的帖子.我创建的服务完全独立于与用户交互的托盘应用程序.然而,我确实通过服务的注册表启动"方法安装了托盘应用程序.服务安装程序现在将安装与用户交互的应用程序......这是最安全和最完整的方法.

Ultimately in order to solve this i took the advice of @marco and the posts he mentioned. I have created the service to be entirely independent of the tray application that interacts with the user. I did however install the Tray application via registry 'start up' methods with the service. The Service installer will now install the application which interacts with the user as well... This was the safest and most complete method.

感谢大家的帮助.

这篇关于从可以与用户交互的 SYSTEM 身份运行的服务启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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