I've changed the code to:
#include <QApplication>
#include <QProcess>
#include <QDebug>
int main(int argc, char **argv)
{
proc.
start("c:\\windows\\system32\\cmd.exe",
QIODevice::ReadWrite);
if (proc.waitForStarted() == false) {
qDebug() << "Error starting cmd.exe process";
qDebug() << proc.errorString();
return (-1);
}
// Show process output
proc.waitForReadyRead();
qDebug() << proc.readAllStandardOutput();
proc.write("dir");
proc.waitForBytesWritten();
proc.waitForReadyRead();
qDebug() << proc.readAllStandardOutput();
proc.close();
return 0;
}
#include <QApplication>
#include <QProcess>
#include <QDebug>
int main(int argc, char **argv)
{
QApplication application(argc, argv);
QProcess proc;
proc.start("c:\\windows\\system32\\cmd.exe", QIODevice::ReadWrite);
if (proc.waitForStarted() == false) {
qDebug() << "Error starting cmd.exe process";
qDebug() << proc.errorString();
return (-1);
}
// Show process output
proc.waitForReadyRead();
qDebug() << proc.readAllStandardOutput();
proc.write("dir");
proc.waitForBytesWritten();
proc.waitForReadyRead();
qDebug() << proc.readAllStandardOutput();
proc.close();
return 0;
}
To copy to clipboard, switch view to plain text mode
and was able to get the this output:
Starting C:\Documents and Settings\Usuario\Meus documentos\Teste\debug\Teste.exe...
"Microsoft Windows XP [versÆo 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Usuario\Meus documentos\Teste\debug>"
""
Starting C:\Documents and Settings\Usuario\Meus documentos\Teste\debug\Teste.exe...
"Microsoft Windows XP [versÆo 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Usuario\Meus documentos\Teste\debug>"
""
To copy to clipboard, switch view to plain text mode
but the dir command output doesn't came out.
Bookmarks