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. Executing commands in cmd.exe using QProcess
Forum Update on Monday, May 27th 2025

Executing commands in cmd.exe using QProcess

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 17.4k Views
  • 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.
  • P Offline
    P Offline
    Project try
    wrote on last edited by
    #1

    Hello,

    I was trying to do this:
    @
    Process->start("cmd.exe",QStringList()<<"C:/Users/Admin/Desktop/test.txt");
    @

    To check if the command works but it doesn't , it shows "" in the app output.

    test.txt is in the desktop and I want to open it.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @
      Process->start("cmd.exe /C start C:/Users/Admin/Desktop/test.txt");

      @

      (Z(:^

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rumpi
        wrote on last edited by
        #3

        Hi,
        try
        Process->start("C:/windows/system32/cmd.exe",QStringList()<<"/C"<<"C:/Users/admin/Desktop/test.txt");
        or wherever your win resides

        1 Reply Last reply
        1
        • P Offline
          P Offline
          Project try
          wrote on last edited by
          #4

          Thank you guys , both works fine , but why /C ? I don't use command line much but I don't think it's a command right ?

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            It executes the commands that follow as a script. Without it, cmd.exe would be opened and wait for input from keyboard.

            (Z(:^

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved