I just want to run another .exe
, and close the caller.
Something like:
var info = new ProcessStartInfo
{
WorkingDirectory = "myDirectory",
FileName = "myFile.exe"
};
Process.Start(info);
Environment.Exit(0);
However, the child process closes at the same time as the parent process.
- The parent is an application, it closes after clicking on a button.
- The child is an application, it closes at the same time with the parent (unwanted).
- The parent is an launcher.
- The child is an application that works when you launch it manually.
I have tried other solutions but they all have the same bad behaviour:
var info = new ProcessStartInfo
{
WorkingDirectory = "myDirectory",
FileName = "cmd",
Arguments = $"/C myFile.exe",
WindowStyle = ProcessWindowStyle.Hidden
};
Process.Start(info);
Environment.Exit(0);
var thread = new Thread(() =>
{
var info = new ProcessStartInfo
{
WorkingDirectory = "myDirectory",
FileName = "myFile.exe"
};
Process.Start(info);
});
thread.Start();
Environment.Exit(0);
Task.Factory.StartNew(() =>
{
var info = new ProcessStartInfo
{
WorkingDirectory = "myDirectory",
FileName = "myFile.exe"
};
Process.Start(info);
});