Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

QProcess: The system cannot find the file specificed even when full path is provided

Here is my full code:

#include <QCoreApplication>

#include "iostream"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QProcess process;
    QString path = "C:\\Windows\\System32\\wbem\\WMIC.exe";
    QString arg  = "cpu get name";
    QStringList arguments; arguments << arg;

    //process.start(path,arguments);
    process.start(path + " " + arg);

    //qDebug() << "Started";
    std::cout << "Started" << std::endl;
    if (!process.waitForFinished()){
        qDebug() << "ERROR" << process.errorString();
    }
    else {
        qDebug() << "Printing output";
        qDebug().noquote() << process.readAllStandardOutput();
    }
    qDebug() << "Finished";

    return 0;
    //return a.exec();
}

I’m tryting to get some hardware specs (liek the model of the GPU Card, or in this case, the CPU) from a Windows machine. I’ve read that the wmic command with the right parameters can get me this. But after severla attempts I’m left with these two non working options:

If arguments is filled with "cpu get name" I get an empty string as a result.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If arguments are nto provided I get the error in the title. Which I assume it means that the QProcess class cannot find the specified file. I don’t know how that is possible as literally added the entire path.

Any help would be appreciated.

Also I’ve read that this might be do to compiler reasons and just in case I’m compiling a 64 bit application with MSVC2019.

>Solution :

Use QStringList arguments = arg.split(" "); and then process.start(path,arguments);.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading