开始从服务中运行的应用程序的系统,可以与用户进行交互 [英] Starting application from service running as SYSTEM that can interact with the user

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

问题描述

目前,我有一个需要从一个窗口服务,我的编码在.NET 3.5中启动一个应用程序。此应用程序正在运行的谁跑的服务,在我的情况下,系统用户的用户。如果作为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);
        }
    }

我只执行try / catch语句,如果我写了GetUserName()(这决定了用户运行的explorer.exe的用户名)的作用不是null

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.

感谢您的帮助大家。

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

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