Tech Support > Microsoft Windows > Development Resources > wmic "process" path failing on XP (Pro SP2, current fixes)
wmic "process" path failing on XP (Pro SP2, current fixes)
Posted by Michael Wojcik on April 28th, 2008


wmic's "process" path doesn't appear to work on XP, at least on the
three systems I've tried. These are all XP Pro SP2 plus current fixes.
It works fine on 2003 Server.

On 2003, "wmic process" writes a list of processes to stdout, just as
expected (and documented).

On the XP boxes, a simple "wmic process" produces the following
astonishingly helpful error message:

-----
c:\> wmic process
Invalid XML content.
-----

Terrific. Now if it mentioned, say, *where* the invalid XML was, it
might be possible to correct the problem. And, of course, this error
does not appear to be documented anywhere.

Other wmic paths I tried work on XP - it's just process that's broken.
Presumably this means a bad wmic configuration file somewhere. Anyone
have any idea where?

(I'm using wmic, by the way, because it's a scriptable way to get
command-line information for running processes that only requires
software that's typically already installed on the platforms I'm
interested in. On machines I control, I have better tools available;
this is for a script we can send to customers.)

--
Michael Wojcik
Micro Focus

Posted by olivier on April 28th, 2008


Michael Wojcik wrote:

If no one can reproduce your bug, it will be difficult to debug it...
But why don't you make an exe, that you can send to customers, which
enumerate processes in C/C++ code ?

Posted by Michael Wojcik on April 28th, 2008


olivier wrote:
If no one could reproduce it, it might be difficult to fix - though
that error message clearly exists in the source, and I doubt it's
difficult to determine what causes it. Were Microsoft not so enamored
of black boxes, I'd have likely found and fixed it already.

But *I* can reproduce it, so your hypothetical is not relevant here.

Perhaps you meant "if no one else can reproduce it"; but that remains
to be seen. Do you have some evidence that no one else can reproduce it?

That fails to meet the already stated requirement of "a scriptable
solution that only requires software that's already installed".

Note that, if "wmic process" worked reliably on XP, I would not need
to send customers anything. I could describe the command over the
phone, for example.

--
Michael Wojcik
Micro Focus


Posted by Boris on April 28th, 2008


On Vista/Win2003 there's TASKLIST command (available via CMD shell).
But I'm not sure if XP has it.

Boris

"Michael Wojcik" <mwojcik@newsguy.com> wrote in message
news:fv52v101cjr@news4.newsguy.com...

Posted by Michael Wojcik on April 29th, 2008


Boris wrote:
tasklist is included in XP, but it doesn't show the process command
line, which is what I need. (I ought to have noted that in the initial
post; but in any case I'm really looking to find out why wmic isn't
working, and how to fix it.)

--
Michael Wojcik
Micro Focus

Posted by Jeff Henkels on April 29th, 2008


Try using Process Explorer from
http://technet.microsoft.com/en-us/s.../default.aspx; it will show
you the command line.

"Michael Wojcik" <mwojcik@newsguy.com> wrote in message
news:fv75s60m4h@news4.newsguy.com...


Posted by boris on April 30th, 2008



"Michael Wojcik" <mwojcik@newsguy.com> wrote in message
news:fv75s60m4h@news4.newsguy.com...
WIN32_Process WMI class that provides all the info you need - all you have
to do: write trivial VBS script using this class.

Boris



Posted by boris on April 30th, 2008


Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery( _
"select * from win32_process" )
For Each objProcess in colProcesses

If objProcess.GetOwner ( User, Domain ) = 0 Then
Wscript.Echo "Process " & _
objProcess.Caption & ": " & objProcess.ProcessId & _
" belongs to " & Domain & _
"\" & User
Else
Wscript.Echo "Problem " & Rtn & _
" getting the owner for process " _
& objProcess.Caption & ": " & objProcess.ProcessId
End If
Wscript.Echo "Command line is: " & objProcess.CommandLine
Next

<<<<<<<<<<<<<<<<<<
Boris



Posted by Michael Wojcik on April 30th, 2008


Jeff Henkels wrote:
Yes, I know. I've been using Process Explorer since it was first
released. That's why, in my original and second posts, I explained
that I am specifically trying to find a *scriptable command-line
solution using only Windows software*.

And more specifically, I'd like to know why "wmic process" doesn't
work on XP.

--
Michael Wojcik
Micro Focus

Posted by Michael Wojcik on April 30th, 2008


boris wrote:
Yes, that's a partial solution for the original problem. (I'd prefer
to use JScript rather than VBScript, as I find the latter language
distasteful, but that shouldn't make any difference to WSH.) And
thanks for the suggestion, as I hadn't gotten around to tracking down
the WMI docs yet.

This still doesn't really address the original requirements, though.
If "wmic process" worked on XP, I'd have a solution that a support
engineer could describe to a customer over the phone. I can't expect
customers to write their own WSH scripts. (Some can, certainly, but
many aren't familiar with the technology.)

And I'd still like to know what's wrong with wmic process on XP.

--
Michael Wojcik
Micro Focus