我似乎无法QProcess
将命令传递给cmd.exe
via stdin
。我也尝试过其他命令行应用程序。
这是我用来尝试和调试的一些简单代码:
prog = "c:/windows/system32/cmd.exe"
arg = [""]
p = QtCore.QProcess()
retval = p.start(prog, arg)
print retval
print p.environment()
print p.error()
p.waitForStarted()
print("Started")
p.write("dir \n")
time.sleep(2)
print(p.readAllStandardOutput())
print(p.readAllStandardError())
p.waitForFinished()
print("Finished")
print p.ExitStatus()
输出:
None
[]
PySide.QtCore.QProcess.ProcessError.UnknownError
Started
{时间流逝}
Finished
PySide.QtCore.QProcess.ExitStatus.NormalExit
QProcess: Destroyed while process is still running.
那么“ dir \n
”命令是否从未发出?