Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QProcess not run "cmd.exe" command and "cmd.exe" not run .bat file.

QProcess not run "cmd.exe" command and "cmd.exe" not run .bat file.

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 2 Posters 604 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.
  • J Offline
    J Offline
    jiajintao
    wrote on last edited by jiajintao
    #1

    Please help me.

    p = QProcess()
    
    def _read():
        print(p.readAllStandardOutput())
        print(p.readAllStandardError())
    
    p.readyReadStandardOutput.connect(_read)
    
    1. p.start( 'tasklist')  ### result is good
    2. p.start('cmd', ['tasklist | findstr "adb"'])  ### reuslt is bad nothing, 
    # reuslt:  b'Microsoft Windows [Version 10.0.22000.556]\r\n(c) Microsoft Corporation. All rights reserved.\r\n\r\nC:\\Users\\User\\project\\autotest_tools\\external_tool\\win_shells>'
    
    3. p.start('tasklist', ['|', 'findstr', 'adb'])  ### result is bad, noting. not run _read()
    4. p.start('cmd',  ['C:/Users/....../shells/test.bat'])  # result is bad, nothing ,  result is to "2"
    
    ------test.bat------
    echo "name:jiajintao"
    
    but, run test.bat on windows cmd.exe is good.
    

    windows11, pyqt6
    I don't know what to do
    I'm not good at English please don't mind

    JonBJ 1 Reply Last reply
    0
    • J jiajintao

      @JonB The question was submitted by mistake and it has now been fixed

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #4

      @jiajintao
      :)

      I presume you have discovered that you need to run cmd /c ... for things which need to be run under cmd (your examples #2, 3 & 4).

      J 1 Reply Last reply
      1
      • J jiajintao

        Please help me.

        p = QProcess()
        
        def _read():
            print(p.readAllStandardOutput())
            print(p.readAllStandardError())
        
        p.readyReadStandardOutput.connect(_read)
        
        1. p.start( 'tasklist')  ### result is good
        2. p.start('cmd', ['tasklist | findstr "adb"'])  ### reuslt is bad nothing, 
        # reuslt:  b'Microsoft Windows [Version 10.0.22000.556]\r\n(c) Microsoft Corporation. All rights reserved.\r\n\r\nC:\\Users\\User\\project\\autotest_tools\\external_tool\\win_shells>'
        
        3. p.start('tasklist', ['|', 'findstr', 'adb'])  ### result is bad, noting. not run _read()
        4. p.start('cmd',  ['C:/Users/....../shells/test.bat'])  # result is bad, nothing ,  result is to "2"
        
        ------test.bat------
        echo "name:jiajintao"
        
        but, run test.bat on windows cmd.exe is good.
        

        windows11, pyqt6
        I don't know what to do
        I'm not good at English please don't mind

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @jiajintao

        QProcess not run "cmd.exe"

        Your code does not attempt to run cmd.exe

        and "cmd.exe" not run .bat file

        It does. You do not run cmd.exe, and there is no .bat file involved here anyway.

        Try to write a proper question, which relates to whatever code you show.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jiajintao
          wrote on last edited by jiajintao
          #3

          @JonB The question was submitted by mistake and it has now been fixed

          JonBJ 1 Reply Last reply
          0
          • J jiajintao

            @JonB The question was submitted by mistake and it has now been fixed

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #4

            @jiajintao
            :)

            I presume you have discovered that you need to run cmd /c ... for things which need to be run under cmd (your examples #2, 3 & 4).

            J 1 Reply Last reply
            1
            • JonBJ JonB

              @jiajintao
              :)

              I presume you have discovered that you need to run cmd /c ... for things which need to be run under cmd (your examples #2, 3 & 4).

              J Offline
              J Offline
              jiajintao
              wrote on last edited by
              #5

              @JonB oh, so simple, thank you. thank you so much
              It's such a simple question that I didn't find it
              thank you so much

              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