What do you want to do:
- Kill the process
- Run it again
There are several ways to get a Process instance in C #. Suppose you know the name of a process:
var process = Process.GetProcessesByName("notepad++")[0];
Then you can do:
process.Kill();
But to start it again, you need to know the path to the process, so before killing it, save the path to the executable file:
var path = process.MainModule.FileName;
And then you can do:
Process.Start(path);
You should check if
GetProcessesByName elements before the first element, but I just wanted to focus on the important thing here.
source share