0

I need to start an application (a simple test.exe) from ASP.net core web application using ProcessStartInfo. The application starts using these parameters:

        var startInfo = new ProcessStartInfo
        {
            FileName = "test.exe",
            Arguments = string.Join("|", args),
            Verb = "runas",    
            //UseShellExecute = false,
            //WindowStyle = ProcessWindowStyle.Hidden,
            //CreateNoWindow = true,
            //RedirectStandardOutput = true,
        };

The App test.exe starts and regularly works as far as the spawn application (the web app) is alive. As soon as the spawn WebApp dies, also the test.exe dies.

As you can see I tried many ProcessStartInfo params, but none of them solved the problem. The question is: Is it possible to launch a simple exe from inside a web app in .net core, and keep it alive independently from the spawn app? Environment is IIS ws2016

Lucia Minerba
  • 119
  • 1
  • 8
  • Maybe you're not in the right direction. See : https://stackoverflow.com/questions/1008886/how-to-create-a-process-that-outlives-its-parent?rq=1 – itminus Mar 12 '19 at 06:24
  • I already read that question, and it should have been the expected behavior. In fact on IIS7 and Windows 7 it works. It seems different on WS2016 and .netcore – Lucia Minerba Mar 12 '19 at 14:44
  • 1
    I don't have a WS2016 server, but I just create a `Test.exe` and Web App with `.NET Core`, and deploy the WebApp under IIS. Even I stop the whole IIS, the `Test.exe` still runs and never exist unless I kill it. I don't believe it's a matter about Windows Server 2016. – itminus Mar 13 '19 at 02:42
  • Didi you rise Test.exe from IIS ? Wich user did you used?. I did the same test, but as soon as IIS dies, Test.exe dies. – Lucia Minerba Mar 17 '19 at 10:05
  • I start `Test.exe` by `Process.Start(startInfo)` within the Web App. Is there a minimal demo online that reproduces ? – itminus Mar 18 '19 at 01:28

1 Answers1

0

You can use Hangfire (http://docs.hangfire.io/en/latest/background-processing/processing-jobs-in-web-app.html) to start the background process independent from the Web App.

Ahmet
  • 906
  • 1
  • 8
  • 22