How to kill process by process name in Qt
process, qt, windows
Solution
You can use Qprocess for this purpose. At the start of your application,Do
Qprocess p;
p.start("pkill processname1");
p.waitForFinished();
p.start("pkill processname2");
p.waitForFinished();
p.start("pkill processname2");
p.waitForFinished();
Or you can use system call directly..
system("pkill processname1");
system("pkill processname2");
system("pkill processname3");
In Windows environment, you can use following commands to kill process
process -k “Process ID”
process -k “Process Name”
You can read more of these here.
Problem
I'm writing desktop application for windows in Qt. I have name of 3 processes that if they are running I want to kill them in the begining of my application. What the best way to do it?(get the status of process by using the process name, and kill it if it's open). code example can help me a lot. Thanks!