Unable to run the WMIC command through QProcess in Qt6.4.0
Unsolved
Qt 6
-
Hi,
As, I mentioned below code, I am unbale to read standard output of the WMIC command. I am using Qt6.4/MSVC2019 to build the code. But this code is working fine with Qt5.12.3/MSVC2017. Kindly help me regarding this.
QProcess objCheckInstance; QStringList args; args << "process where \"Caption=\'" + a.applicationName() + ".exe\'\" get processid"; objCheckInstance.start("wmic", args); if(objCheckInstance.waitForStarted()) { QString qszOutput; if(objCheckInstance.waitForFinished()) { qszOutput.clear(); qszOutput = objCheckInstance.readAllStandardOutput(); qDebug() << "test" << qszOutput; }else { qDebug() << "test2" ; } }
Thanks,
-
@Pradson What about adding error handling?
For example https://doc.qt.io/qt-6/qprocess.html#errorOccurred
You also did not mention whether waitForStarted()/waitForFinished() time out or not. -