3

我有一个正在运行的服务,该服务将创建一个新线程来启动一个进程。

它启动的进程将调用一个 MSI,该 MSI 将实质上停止原始父服务(调用启动 msi 的进程的服务)

截至目前,该进程终止导致 MSI 在完成执行之前失败。

startInfo.FileName = "UpdateInstaller.exe";
startInfo.Arguments = "ParentServiceName.exe";
startInfo.UseShellExecute = true;
startInfo.RedirectStandardOutput = false; //Edited as per comment below. Still wont work 

new Thread(() =>
{
    Thread.CurrentThread.IsBackground = true;
    Process.Start(startInfo);
}).Start();

关于如何运行这个过程但保持它活着的任何想法,即使在父母死后也是如此?

4

1 回答 1

0

您的代码启动的这个进程在调用代码终止后保持打开状态。举个例子——如果你有一个控制台应用程序会自然退出这里,记事本进程将在它“消失”后保持打开状态:

    static void Main(string[] args)
    {
        var startInfo = new ProcessStartInfo
        {
            FileName = "notepad.exe",
            UseShellExecute = true,
            RedirectStandardOutput = false
        };

        new Thread(() =>
        {
            Thread.CurrentThread.IsBackground = true;
            Process.Start(startInfo);
        }).Start();
    }
于 2013-12-20T13:03:43.017 回答