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 wont run executable.
Qt 6.11 is out! See what's new in the release blog

QProcess wont run executable.

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 3.7k Views 1 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
    rafael
    wrote on last edited by
    #1

    I used the code below to start a new process. It will not run the executable.
    what am i missing?

    I have tried both

    QProcess p;
    p.start(QString("C:\\Progra~2\\Notepad++\\notedpad++.exe"));
    
    QProcess::startDetached(QString("C:\\Program Files (x86)\\Notepad++\\notedpad++.exe"));
    
    1 Reply Last reply
    0
    • P Offline
      P Offline
      patrik08
      wrote on last edited by
      #2

      Try...
      http://doc.qt.io/qt-5/qdesktopservices.html
      QDesktopServices::openUrl("app location"); or read regedit default txt editor...

      Or argument file for notedpad++.exe....

      QStringList comandlist
      comandlist << filetoopen.txt 
       QString cmd = QString("notepad.exe");
        QProcess *process = new QProcess(this);
        process->setReadChannelMode(QProcess::MergedChannels);
        process->start(cmd, comandlist, QIODevice::ReadOnly);
        if (!process->waitForFinished()) {
          lstr = QString();
        } else {
          lstr = QString(process->readAll().constData());
        }
      
      R 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Did you check the status code of the process for more information ?

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

        1 Reply Last reply
        0
        • P patrik08

          Try...
          http://doc.qt.io/qt-5/qdesktopservices.html
          QDesktopServices::openUrl("app location"); or read regedit default txt editor...

          Or argument file for notedpad++.exe....

          QStringList comandlist
          comandlist << filetoopen.txt 
           QString cmd = QString("notepad.exe");
            QProcess *process = new QProcess(this);
            process->setReadChannelMode(QProcess::MergedChannels);
            process->start(cmd, comandlist, QIODevice::ReadOnly);
            if (!process->waitForFinished()) {
              lstr = QString();
            } else {
              lstr = QString(process->readAll().constData());
            }
          
          R Offline
          R Offline
          rafael
          wrote on last edited by rafael
          #4

          thank found the answer now.

           QString cmd = QString("\"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\"");
          
          Epiales666E 1 Reply Last reply
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Glad you found out and thanks for sharing !

            Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

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

            1 Reply Last reply
            0
            • R rafael

              thank found the answer now.

               QString cmd = QString("\"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\"");
              
              Epiales666E Offline
              Epiales666E Offline
              Epiales666
              wrote on last edited by Epiales666
              #6

              @rafael

              I"m glad you found a solution. In case you have other areas, here's another way it works.

                  QDesktopServices::openUrl(QUrl("file:///C:/windows/notepad", QUrl::TolerantMode));
              

              I've found out there are about 4 different ways to run exe programs. When one doesn't work, the other 3 will lol. At least one of them will anyway. Since I'm here, I'll list the four different ways that I've found for others that may have any similar issues:

              1. QDesktopServices::openUrl(QUrl("file:///C:/windows/notepad", QUrl::TolerantMode));
                
              2.  system("C:/WINDOWS/system32/osk.exe");
                
              3.   QProcess::startDetached("\"C:\\Program Files\\WinHTTrack\\WinHTTrack.exe\"");
                
              4.  QString cmd = QString("\"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\"");
                

              Hope this helps someone.

              Be Blessed!
              Epiales666

              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