I've some problems with killing a process using taskkill
.
My code:
QStringList args;
args << "/F";
args << "/IM testApp.exe";
QProcess::execute("taskkill", args); //Should be 'taskkill /IM testApp.exe /F'
Output (translated from german):
ERROR: Invalid argument - "/IM testApp.exe".
Type "TASKKILL /?" to show the syntax.
CodePudding user response:
"/IM testApp.exe" makes a single arg, but should be two args. You get the command taskkill /F "/IM testApp.exe"
. The proper invocation is
QStringList args;
args << "/F";
args << "/IM";
args << "testApp.exe";
QProcess::execute("taskkill", args);