Discussion:
system("wmi.exe os get serialnumber > xxx") hangs on Virtual PC running XP
(too old to reply)
ppa
2011-10-12 07:35:02 UTC
Permalink
Hello

I am doing a system() call to get the output of wmi in a temp file xxx a
follows

system("wmic.exe os get serialnumber > xxx"

It creates the temp file xxx but the call doesn't return. I need to kill i
an
nothing is written to temp file xxx

Why ? Is there any restriction of running wmic on Virtual machine

The same things works fine from command prompt on the Virtual machine withou
any teouble

Kindly help

Thank you.
Tom Lavedas
2011-11-30 13:44:36 UTC
Permalink
Hello,
 I am doing a system() call to get the output of wmi in a temp file xxx as
 system("wmic.exe os get serialnumber > xxx")
 It creates the temp file xxx but the call doesn't return. I need to kill it
and
 nothing is written to temp file xxx.
 Why ? Is there any restriction of running wmic on Virtual machine ?
 The same things works fine from command prompt on the Virtual machine without
 any teouble.
 Kindly help.
 Thank you.
I suspect that the redirection is at least part of the problem. The
comamnd processor is required to support it. Generally, System()
shells do not invoke it. Try this and see if it doesn't fix
things ...

system("cmd /cwmic.exe os get serialnumber > xxx")

Also, if you are working in a higher level language, why shell out to
the command prompt, since WMI services are easy to access through the
DCOM interface.
_____________________________
Tom Lavedas

Loading...