Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 717823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:27:23+00:00 2026-05-14T05:27:23+00:00

few days ago i asked about how to get all running processes in the

  • 0

few days ago i asked about how to get all running processes in the system using QProcess.
i found a command line that can output all processes to a file:

C:\WINDOWS\system32\wbem\wmic.exe” /OUTPUT:C:\ProcessList.txt PROCESS get Caption

this will create C:\ProcessList.txt file contains all running processes in the system.
i wonder how can i run it using QProcess and take its output to a variable.

it seems every time i try to run it and read nothing happens:

QString program = "C:\\WINDOWS\\system32\\wbem\\wmic.exe";
QStringList arguments;
arguments << "/OUTPUT:C:\\ProcessList.txt" <<"PROCESS"<< "get"<< "Caption";

process->setStandardOutputFile("process.txt");
process->start(program,arguments);

QByteArray result = process->readAll();

i prefer not to create process.txt at all and to take all the output to a variable…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:27:23+00:00Added an answer on May 14, 2026 at 5:27 am

    You can run wmic.exe with “/OUTPUT:STDOUT” switch to print the process info directly to stdout. However, I was unable to read this info through QProcess API and save it in variable. Here’s the code I used:

    #include <QtCore/QCoreApplication>
    #include <QProcess>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        QProcess process;
        process.setReadChannel(QProcess::StandardOutput);
        process.setReadChannelMode(QProcess::MergedChannels);
    //    process.start("cmd.exe /C echo test");
        process.start("wmic.exe /OUTPUT:STDOUT PROCESS get Caption");
    
        process.waitForStarted(1000);
        process.waitForFinished(1000);
    
        QByteArray list = process.readAll();
        qDebug() << "Read" << list.length() << "bytes";
        qDebug() << list;
    }
    

    This code successfully captures output of “cmd.exe /C echo test”, but doesn’t work on wmic.exe. It seems that process wmic.exe is never finished, and I suppose it’s stdout is never flushed so you don’t receive anything throught QProcess::readAll().

    That’s all help I can give you. Maybe you, or some other SO user will find bug in the snippet above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Notepad++ for python development, and few days ago I found out about
A few days ago I asked here about how to add src attribute to
A few days ago I asked about passing a data structure from java to
few days ago I asked here about implementing USB. Now, If I may, would
so I asked here few days ago about C# and its principles. Now, if
I asked a question a few days ago about how to customise the calendar
A few days ago, I asked why its not possible to store binary data,
In response to a question I asked a few days ago, I'm attempting to
Guys I've asked few days ago a question and didn't have really time to
A few days ago i asked this question: Displaying images from Facebook photo albums

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.