Using wmic to get info
-
wrote on 24 Sept 2014, 17:18 last edited by
I'm making a QT application to retrieve info from OS.I'm trying to access wmic.exe directly ( i added the path Windows\System32\wbem\ previously in the code ) and i don't want to use it through cmd.The code works fine in Windows Vista/7 but doesnt work in Windows XP
Sample code :
@ QProcess process;
process.start(QString("wmic bios get serialnumber"));
process.waitForStarted();
process.waitForFinished();
qDebug()<<process.readAll();
system("pause");@Note : I'm using QT 4.6
Any Ideas ?
-
Hi and welcome to devnet,
Are you sure the command is available on XP and at the same place ?
-
wrote on 24 Sept 2014, 20:46 last edited by
yes im pretty sure 100% u can even launch it from there and type the command and will work fine.I've been searching for a solution for days and no one is solving it.I'd appreciate it alott if u figure it out
-
wrote on 24 Sept 2014, 21:30 last edited by
Are there any messages error, etc printed out ?
What if you remove system("pause"); line ? -
wrote on 25 Sept 2014, 02:55 last edited by
No error messages are printed out . In win xp it just shows the console dash like forever no results are shown and program never ends while in win vista/7 normal results are shown.
I tried removing system("pause") same issue.
-
Did you read the standard out/error channels of QProcess ?
-
wrote on 25 Sept 2014, 18:38 last edited by
There is literally 0 errors , that's why it's making me crazy
-
Did you check whether waitForStarted and waitForFinished returns true ?
-
wrote on 25 Sept 2014, 19:11 last edited by
yes so if i set a short time for waitforfinished lets say 2 sec , it will return empty result and program successfully ends
-
What's the exit code ?
-
wrote on 2 Oct 2014, 08:26 last edited by
Solved same problem a year ago.
This is part of working function from my app:@...
QString Arguments = "/node:" + IP + " " + Args + " get /format:list";
...
Process.setProcessChannelMode (QProcess::MergedChannels);
Process.start ("wmic");
Process.waitForStarted ();
Process.write (Arguments.toUtf8 ());
Process.closeWriteChannel();while (Process.waitForReadyRead ())
{
while (Process.canReadLine())
{
...@
1/11