I use wmic like the following code.But It start this cmd error,and return after call p.waitForStarted.

Does sb kown why?

Qt Code:
  1. QString cmdTask = "wmic.exe /OUTPUT:STDOUT process where name=\"startServer.exe\" get executablepath";
  2. QStringList output = execute(cmdTask);
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. QStringList execute(const QString &cmd) {
  2. p.start(cmd);
  3. if (!p.waitForStarted()) {
  4. return QStringList();
  5. }
  6.  
  7. if (!p.waitForFinished()) {
  8. return QStringList();
  9. }
  10. int res = p.exitCode();
  11. if (res) { //error
  12. return QStringList();
  13. }
  14. QByteArray data = p.readAllStandardOutput()
  15.  
  16. QString ds = QString::fromLocal8Bit(data);
  17.  
  18. QStringList out = ds.split("\r\n");
  19.  
  20. return out;
  21. }
To copy to clipboard, switch view to plain text mode