I use wmic like the following code.But It start this cmd error,and return after call p.waitForStarted.
Does sb kown why?
QString cmdTask
= "wmic.exe /OUTPUT:STDOUT process where name=\"startServer.exe\" get executablepath";
QString cmdTask = "wmic.exe /OUTPUT:STDOUT process where name=\"startServer.exe\" get executablepath";
QStringList output = execute(cmdTask);
To copy to clipboard, switch view to plain text mode
p.start(cmd);
if (!p.waitForStarted()) {
}
if (!p.waitForFinished()) {
}
int res = p.exitCode();
if (res) { //error
}
return out;
}
QStringList execute(const QString &cmd) {
QProcess p;
p.start(cmd);
if (!p.waitForStarted()) {
return QStringList();
}
if (!p.waitForFinished()) {
return QStringList();
}
int res = p.exitCode();
if (res) { //error
return QStringList();
}
QByteArray data = p.readAllStandardOutput()
QString ds = QString::fromLocal8Bit(data);
QStringList out = ds.split("\r\n");
return out;
}
To copy to clipboard, switch view to plain text mode
Bookmarks