为什么Windows服务无法启动​​的外部应用程序? [英] Why does Windows Service not launch external App?

查看:152
本文介绍了为什么Windows服务无法启动​​的外部应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一个Windows服务启动外部应用程序。当我开始我的服务它不会加载该应用程序了。



有没有在事件视图中报告或者错误。它只是说在服务启动,并成功地停止



以下是的OnStart和调用OnStop代码:



 公共部分类TestService的:ServiceBase 
{
公共流程应用程序{搞定;组; }

公共TestService的()
{
的InitializeComponent();

=应用新的Process();

}

保护覆盖无效的OnStart(字串[] args)
{
App.StartInfo.FileName = @C:\Program文件(86)\SourceGear\DiffMerge\DiffMerge.exe
App.Start();
}

保护覆盖无效调用OnStop()
{
App.Close();
}
}


解决方案

如果你在Vista中,Windows 7或Windows Server 2008上运行,你的可执行文件是一个Windows应用程序(不是命令行),那么就不会因为会话0隔离运行,这意味着在最新的Windows操作系统的可用的图形手柄服务



我们发现的唯一的解决方法是启动一个RDP会话,然后该会话内启动应用程序,即使是复杂得多。


I am trying to get a Windows Service to launch an external application. When I start my service it doesn't load the application up.

There are no errors reported in the event view either. It just says the service started and stopped successfully.

The following is the OnStart and OnStop code:

public partial class TestService : ServiceBase
    {
        public Process App { get; set; }

        public TestService()
        {
            InitializeComponent();

            App = new Process();

        }

        protected override void OnStart(string[] args)
        {
            App.StartInfo.FileName = @"C:\Program Files (x86)\SourceGear\DiffMerge\DiffMerge.exe";
            App.Start();
        }

        protected override void OnStop()
        {
            App.Close();
        }
    }

解决方案

If you are running on Vista, Windows 7 or Server 2008 and your executable is a windows application (Not Command-Line), then it will not run due to Session 0 Isolation, meaning there are no graphical handles available to services in the newest Windows OS's.

The only workaround we have found is to launch an RDP Session, and then launch your application within that session even though that is far more complicated.

这篇关于为什么Windows服务无法启动​​的外部应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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