WMI - invalid syntax error?
tim.golden at viacom-outdoor.co.uk
Tue Jan 3 05:15:04 EST 2006
| Sent: 30 December 2005 16:15
| To: python-list at python.org
| Subject: Re: WMI - invalid syntax error?
| py wrote:
| >Something must be happening somewhere causing it
| > to get fouled up. I'm gonna try on a different PC.
| I tried on another PC, same problem.
| Also, I added "reload(wmi)" before I create an instance of
| wmi.WMI just
| to see what happens, so I hve...
| import wmi
| def ppn(machine=None):
| wmiObj = wmi.WMI(machine)
| except Exception, e:
| print "Error: " + str(e)
| ...now I get this as the error message..
| Error: (-2147221020, 'Invalid syntax', None, None)
| Slightly different than before...but same message.
Hmmm. I think I'm now in the unusual situation of having
*too much* information to solve the problem. The thing I'm
straining for is the minimum reproducible situation. At
first it looked as though it was down to running the code
from a file rather than at the interpreter. Is that still
the case? Your previous post about the monikers suggests
that running the code twice -- in any way -- triggered
the problem. Is that true? The code above introduces the
extra complication of a reload which I'm afraid just muddies
To confirm, your code above runs from a file any number
of times without issue on my (WinXP Python 2.4.2) box
using wmi 0.6b.
Behind the scenes, the wmi module is doing something
x = win32com.client.GetObject ("winmgmts:")
Now if I deliberately fudge that moniker, I'll
get the error message you show above, which is
what I expected with an ill-formed moniker.
x = win32com.client.GetObject ("winmgmtxx:")
# pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None)
Googling for your original error code (-0x7ffbfe1c) which
is 800401E4 in top-bit-set hex, most of the hits suggest
that WMI is not installed on the box in question (typically
because it's a Win98 or WinNT install without the WMI download).
But you're on WinXP, so that can't be it.
I'm afraid I'm still mystified; it's frustrating because
I can't even reproduce the situation.
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
More information about the Python-list