Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess ReadAll Output from EXE
Forum Updated to NodeBB v4.3 + New Features

QProcess ReadAll Output from EXE

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 543 Views 2 Watching
  • 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.
  • R Offline
    R Offline
    Ryan R
    wrote on last edited by Ryan R
    #1

    Hello guys,

    So I have these lines of C++:

                QProcess qp1;
    
                qp1.start("C:\\Users\\ariie\\Desktop\\moboTemp.bat");
                qp1.waitForFinished();
                qDebug() << "qp1:" << qp1.readAll();
    

    That works perfectly; it runs a WMIC command to get my Motherboard temperature, and displays its' standard output.
    The output in this case is "qp1: "29.85 Degrees Celsius\r\n"".

    However, now I want to replace the bat file with an exe. In particular, I'm trying to access a NVIDIA EXE that collects GPU information such as temperature, load, etc..

    First of all, the file path location is "C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.exe", which brings me to my first question. NVIDIA -SPACE- Corporation and Program -SPACE- Files. Is this OK? I know that some environments can't deal with spaces, and it isn't really possible to change the location of NVSMI without reinstalling my GPU drivers.

    Secondly, how do I add command-line parameters to that EXE via QProcess? Do I just add them on the end of the EXE like regular parameters, or do I have to add more arguments to QProcess.start?

    Here is the full command-line string I'm trying to get output from:

    "C:\\Program Files\\NVIDIA Corporation\\NVSMI\\nvidia-smi.exe" --query-gpu=clocks.gr,fan.speed,power.draw,temperature.gpu,utilization.gpu --format=csv,noheader
    

    Which displays the following output in cmd:

    1177 MHz, 31 %, 72.56 W, 55, 34 %
    

    But in Qt, when I use the following:

    qp1.start("'C:\\Program Files\\NVIDIA Corporation\\NVSMI\\nvidia-smi.exe' --query-gpu=clocks.gr,fan.speed,power.draw,temperature.gpu,utilization.gpu --format=csv,noheader");
                qp1.waitForFinished();
                qDebug() << "qp1:" << qp1.readAll();
    

    I simply get "" as a result. I'm fairly certain it's something to do with the syntax; either I have to do some wizardry to eliminate the space in the file path, or I'm not using QProcess correctly.

    Does anyone have any hints? Any help is greatly appreciated.

    Thanks,
    Ryan

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you try using escaped double quotes for your path rather than single quotes ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      3
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Pass the parameter separately with setArguments()

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        4
        • SGaistS SGaist

          Hi,

          Did you try using escaped double quotes for your path rather than single quotes ?

          R Offline
          R Offline
          Ryan R
          wrote on last edited by
          #4

          As usual, @SGaist, you're right!

          Solution is:

                      QProcess qp1;
          
                      qp1.start("\"C:\\Program Files\\NVIDIA Corporation\\NVSMI\\nvidia-smi.exe\" --query-gpu=clocks.gr,fan.speed,power.draw,temperature.gpu,utilization.gpu --format=csv,noheader");
                      qp1.waitForFinished();
                      qDebug() << "qp1:" << qp1.readAll();
          

          Thanks,
          Ryan

          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