从Windows服务调用时的Process.Start不工作 [英] Process.Start does not work when called from windows service

查看:1017
本文介绍了从Windows服务调用时的Process.Start不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 8的我正在运行的窗口服务。此服务是应该由

On Windows 8 I am running a windows service. This service is supposed to start a program by

Process.Start(exePath);

但是这个过程会立即退出 - 不执行的主要过程,即使第一线。之前,在Windows 7上运行相同的过程,相同的服务时,一切正常。

But the process exits immediately - even first line in the Main procedure is not executed. Before, when running the same process in same service on Windows 7, everything worked fine.

我怎样才能使它重新工作?如何正确地从一个窗口服务启动一个进程?

How can I make it work again? How to properly start a process from a windows service?

推荐答案

找到了解决办法。过程是这样开始:

Found the solution. Process has to be started like this:

ProcessStartInfo info = new ProcessStartInfo(exePath);
info.CreateNoWindow = true;
info.UseShellExecute = false;
Process.Start(info);

出于某种原因,创建一个shell窗口,在系统的后台时有问题,priviledges。

For some reason there are problems with priviledges when creating a shell window in the background of the SYSTEM.

这篇关于从Windows服务调用时的Process.Start不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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