Important: Please read the Qt Code of Conduct -

Running multiple cmd.exe simultaneously using QProcess

  • Hi all,

    I am currently trying to run a few batch files from Qt. Currently I am using QProcess to trigger cmd.exe and provide the batch file path as the argument. Since I have multiple files, is it possible to run more than one cmd.exe at the same to run different batch files in each cmd.exe?

    If yes, do I have to create multiple QProcess for each cmd.exe?

  • Qt Champions 2017

    QProcess can launch one process. You need to create multiple instances

  • By instances you mean QProcess? Is there a way to dynamically create the QProcess?

    For example, each time a button is pressed, a new QProcess is created to run the batch file in new cmd.exe

  • Qt Champions 2017

    bq. Is there a way to dynamically create the QProcess?

    What do you mean here ? Is it not as simple as this ?

    QProcess *proc = new QProcess.

  • Hi Dheerendra, thanks for the input.

    Sorry my question was not clear. What I meant is that, I want to run the process everytime the user press a button.

    @QProcess *proc = new Qprocess @

    does produce the process dynamically, but how do I delete them once the process is completed. My concern is because I m creating this Qprocess inside the slot that is connected with the button click. So won't I lose the pointer once I the program exit the slot function?

  • Qt Champions 2017

    Are you launching all process simultaneously ? Or are u running them one at a time ? Some how you need keep reference to all qprocess variable, connect with finished signal and delete qprocess pointer variable. Hope this helps.

  • Hi Dheerendra, thanks for the input. Yes I got the rough idea now.
    Referring to your question, I may run more than one process simultaneously.

Log in to reply