Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Unable to run the WMIC command through QProcess in Qt6.4.0
Forum Updated to NodeBB v4.3 + New Features

Unable to run the WMIC command through QProcess in Qt6.4.0

Scheduled Pinned Locked Moved Unsolved Qt 6
3 Posts 3 Posters 320 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pradson
    wrote on last edited by
    #1

    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,

    jsulmJ JonBJ 2 Replies Last reply
    0
    • P Pradson

      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,

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Pradson

        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,

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Pradson
        Apart from obviously putting in error handling if you want help with errors as @jsulm says. Did you try making that command line separate arguments instead of a single one? Did you try running just a command with empty arguments of wmic?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved