Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72456

QProcess fails to open cmd.exe console Windows 10/7

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P1: Critical
    • None
    • 5.11.3, 5.12.0
    • Core: I/O
    • None
    • Windows 10/7
    • Windows

    Description

      Currrently, QProcess won't open a Windows cmd.exe console. This worked well in Qt 5.6. The example below has been tested with 5.12 & Winsows 10 & Windows 7. Test project attached.

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      #ifdef __WIN32__
       #include "windows.h"
      #endif
      
      #include <QProcess>
      #include <QDir>
      #include <QDesktopServices>
      #include <QObject>
      
      MainWindow::MainWindow(QWidget *parent) :
       QMainWindow(parent),
       ui(new Ui::MainWindow)
      {
       ui->setupUi(this);
      }
      
      MainWindow::~MainWindow()
      {
       delete ui;
      }
      
      void MainWindow::on_pushButton_clicked()
      {
       QProcess p;
       p.setProgram("cmd.exe");
       p.setArguments(\{"/k","test.bat"});
      
      
       p.setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments
       *args)
      
      {
       args->flags &= ~CREATE_NO_WINDOW;
       });
       p.startDetached();
      
      }
      
      void MainWindow::on_pushButton_2_clicked()
      {
       QString cstring = "cmd /k " +QDir::currentPath()+"/test.bat";
       QProcess::startDetached(cstring);
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jbornema Joerg Bornemann
            jedevnull Jed Evnull
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes