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. How to execute a process with QProcess
Forum Updated to NodeBB v4.3 + New Features

How to execute a process with QProcess

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 769 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.
  • AzadshahrA Offline
    AzadshahrA Offline
    Azadshahr
    wrote on last edited by
    #1

    Hi, I have a program in my project directory which is called PsExec.exe. I wanted to execute this process with the parameter "//machine cmd.exe". I written the following code but it doesn't work:

    QString program = "PsExec";
        QString arguments = "\\\\";
        arguments.append(f_targetComputerName);
    
     QStringList argumentList;
    
     argumentList << arguments << "cmd.exe";
    
     QProcess *myProcess = new QProcess(this);
     myProcess->start(program, argumentList);
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What errors do you get ?
      What is the final list of arguments ?

      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
      • AzadshahrA Offline
        AzadshahrA Offline
        Azadshahr
        wrote on last edited by
        #3

        It doesn't execute the PsExec at all. I don't know where is the problem. The final list of arguments is "//Machine cmd.exe" which I wanted to pass to PsExec.exe.

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

          QProcess offers several APIs to get the output of the application you executed, its status, error informations. Did you use them ?

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

          AzadshahrA 1 Reply Last reply
          1
          • SGaistS SGaist

            QProcess offers several APIs to get the output of the application you executed, its status, error informations. Did you use them ?

            AzadshahrA Offline
            AzadshahrA Offline
            Azadshahr
            wrote on last edited by
            #5

            @SGaist No, I didn't use them. I know the process is executing but it doesn't show the console environment of the PsExec. I don't know where is the problem.

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

              Well... Use QProcess's API to get that 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
              1
              • hskoglundH Online
                hskoglundH Online
                hskoglund
                wrote on last edited by
                #7

                Hi, maybe you forgot the -accepteula switch? Also, usually when QProcessing tricky stuff startDetached works better, say like this:

                QProcess::startDetached("psexec",QStringList({"-accepteula","\\\\" + f_targetComputerName,"cmd.exe"}));
                
                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