Pythonwin can't resolve WMI instances

Benjamin Derstine bend at ecollege.com
Fri Oct 20 12:08:23 EDT 2000


When I try to run the exact code below (except for changing the computer
name) I get an "AttributeError: Name" error for the last line.  I inspect
the object type and the object type is correct- ISWbemObject.  It seems that
Pythonwin can only see the generic classes for WMI and can't seem to access
instances and their dynamic properities. I also tried enumerating the
software products on my machine and got the same result- the returned
objects have class types that are correct but no instance information is
accessible.  I'm running a Win2000 system and when I run the equivalent code
using VBS (with WSH) everything works fine. Is there something else I need
to do to make Pythonwin aware of WMI?

Ben

Subject: Re: System information on Windows?
Date: 09/19/2000
Author: Roger Upole <rupole at compaq.net>


      If you don't mind installing WMI (a free download from Microsoft) on
all the machines in question, you can do things like this:

      import win32com.client
      wmi = win32com.client.Dispatch('wbemscripting.swbemlocator')
      rmt_mach = wmi.ConnectServer('machine name')
      cpus = rmt_mach.InstancesOf('Win32_Processor')
      for cpu in cpus:
          print cpu.Name, cpu.CurrentClockSpeed, cpu.Description,
cpu.L2CacheSize

      For my machine, this returns
          Intel Pentium III processor 450 x86 Family 6 Model 7 Stepping 3
512

      HTH
      Roger Upole









More information about the Python-list mailing list