62,046
社区成员
发帖
与我相关
我的任务
分享
A.exe
Process proB = new Process();
proB.StartInfo.FileName = "B.exe";
proB.StartInfo.Arguments = Process.GetCurrentProcess().Id.ToString();
proB.Start();
B.exe
static void Main(string[] args)
{
int proAId;
if(args.Length > 0)
{
int.TryParse(args[0], out proAId);
}
// do something
if(proAId > 0)
{
Process proA = Process.GetProcessById(proAId);
if(proA != null)
{
proA.Kill();
}
}
}
B.exe
Process proA = Process.GetProcessesByName("A.exe").FirstOrDefault();
if(proA != null)
{
proA.Kill();
}
Process p = new Process();
p.StartInfo.FileName = "notepad.exe";
p.Start();
p.WaitForExit();
Environment.Exit(0);