我只想运行另一个.exe
,然后关闭呼叫者。
类似的东西:
var info = new ProcessStartInfo
{
WorkingDirectory = "myDirectory",
FileName = "myFile.exe"
};
Process.Start(info);
Environment.Exit(0);
但是,子进程与父进程同时关闭。
我尝试了其他解决方案,但是它们都具有相同的不良行为:
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);
});
答案 0 :(得分:0)
这很愚蠢...只是在调试模式下不起作用。 这不是错误,而是故意的(幸运的是它是这样设计的)。
(使用Rider JetBrains)