By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,538 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,538 IT Pros & Developers. It's quick & easy.

WMI Help

P: n/a
Hello,
When I run the following at an interactive interpreter on Windows XP, I get
the expected results. But if I save it to a file and run it, it generates
the following error. (And it generates the same error either way on Windows
2000)

import wmi
c=wmi.WMI()
for item in c.win32_PhysicalMedia():
print item
Traceback (most recent call last):
File "<pyshell#32>", line 1, in ?
for item in c.win32_PhysicalMedia():
File "wmi.py", line 850, in __getattr__
return getattr (self._namespace, attribute)
File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line 489,
in __getattr__
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError:
winmgmts:{impersonationLevel=impersonate,authentic ationLevel=default}//./roo
t/cimv2.win32_PhysicalMedia

Any help is appreciated.
Louis
Jul 13 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi!

Win32_PhysicalMedia WMI class is available only on Windows 2003 or XP

Then, swap Admin <=Normal_user

--
@-salutations

Michel Claveau
Jul 13 '06 #2

P: n/a
Re!

This script run on my XP :
import win32com.client
WMIS = win32com.client.GetObject(r"winmgmts:root\cimv2")
objs = WMIS.ExecQuery("select * from Win32_PhysicalMedia")
for obj in objs:
print obj.SerialNumber
print obj.Tag
print

--
@-salutations

Michel Claveau
Jul 13 '06 #3

P: n/a
"Michel Claveau" <mc***********@mclaveauPas.De.Spam.comwrote in message
news:mn***********************@mclaveauPas.De.Spam .com...
Re!

This script run on my XP :
import win32com.client
WMIS = win32com.client.GetObject(r"winmgmts:root\cimv2")
objs = WMIS.ExecQuery("select * from Win32_PhysicalMedia")
for obj in objs:
print obj.SerialNumber
print obj.Tag
print
Thank you for the input. Strange that this does not return the serial number
reported by other hardware utilities (SIW for one) and on both of my
machines this number ends with 202020202020202020202020??? Thanks again.
Louis
Jul 13 '06 #4

P: n/a
3c273 wrote:
Hello,
When I run the following at an interactive interpreter on Windows XP, I get
the expected results. But if I save it to a file and run it, it generates
the following error. (And it generates the same error either way on Windows
2000)

import wmi
c=wmi.WMI()
for item in c.win32_PhysicalMedia():
print item
A couple of things:

+ As someone else has pointed out, Win32_PhysicalMedia
appears to be new to XP/2k3. (This happens quite a lot
with WMI classes; you need to check the small-print).
So that explains why it won't work on your Win2K box
nor on mine.

+ In addition, the bit after the "c." (here, Win32_PhysicalMedia)
is case-sensitive. So you have to put c.Win32_PhysicalMedia
(notice the capital "W"). I'm not actually sure why this should
be, and when I get a moment I'll take a look at the code to
see, but it's true nonetheless.

Under the covers, the module is doing exactly what
Michel showed you in his second post (WMIS = GetObject etc.)
Strange that this does not return the serial number
reported by other hardware utilities (SIW for one) and on both of my
machines this number ends with 202020202020202020202020???
Strange indeed. Unfortunately, what you see is what you get
with WMI. I don't have access to an XP machine to test, but
let me know if this code doesn't work:

<code>
import wmi
c = wmi.WMI ()
for item in c.Win32_PhysicalMedia ():
print item

</code>

Good luck with WMI

TJG
Jul 13 '06 #5

P: n/a
"Tim Golden" <ma**@timgolden.me.ukwrote in message
news:ma***************************************@pyt hon.org...
3c273 wrote:
Hello,
When I run the following at an interactive interpreter on Windows XP, I
get
the expected results. But if I save it to a file and run it, it
generates
the following error. (And it generates the same error either way on
Windows
2000)

import wmi
c=wmi.WMI()
for item in c.win32_PhysicalMedia():
print item

A couple of things:

+ As someone else has pointed out, Win32_PhysicalMedia
appears to be new to XP/2k3. (This happens quite a lot
with WMI classes; you need to check the small-print).
So that explains why it won't work on your Win2K box
nor on mine.

+ In addition, the bit after the "c." (here, Win32_PhysicalMedia)
is case-sensitive. So you have to put c.Win32_PhysicalMedia
(notice the capital "W"). I'm not actually sure why this should
be, and when I get a moment I'll take a look at the code to
see, but it's true nonetheless.

Under the covers, the module is doing exactly what
Michel showed you in his second post (WMIS = GetObject etc.)
Strange that this does not return the serial number
reported by other hardware utilities (SIW for one) and on both of my
machines this number ends with 202020202020202020202020???

Strange indeed. Unfortunately, what you see is what you get
with WMI. I don't have access to an XP machine to test, but
let me know if this code doesn't work:

<code>
import wmi
c = wmi.WMI ()
for item in c.Win32_PhysicalMedia ():
print item

</code>

Good luck with WMI

TJG
Thanks for your input. Strangely enough, it now works whether the Win32 is
captalized or not??? I must have had a typo in there somewhere. Thanks
again.
Louis
Jul 13 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.