简体   繁体   中英

Error while kill process with QProcess::execute()

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.

"/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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM