QProcess not run "cmd.exe" command and "cmd.exe" not run .bat file.
-
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 -
@jiajintao
:)I presume you have discovered that you need to run
cmd /c ...for things which need to be run undercmd(your examples #2, 3 & 4). -
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 mindQProcess not run "cmd.exe"
Your code does not attempt to run
cmd.exeand "cmd.exe" not run .bat file
It does. You do not run
cmd.exe, and there is no.batfile involved here anyway.Try to write a proper question, which relates to whatever code you show.
-
@jiajintao
:)I presume you have discovered that you need to run
cmd /c ...for things which need to be run undercmd(your examples #2, 3 & 4). -
@jiajintao
:)I presume you have discovered that you need to run
cmd /c ...for things which need to be run undercmd(your examples #2, 3 & 4).