WMI Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 3c273

    #1

    WMI Help

    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_Physica lMedia():
    print item


    Traceback (most recent call last):
    File "<pyshell#3 2>", line 1, in ?
    for item in c.win32_Physica lMedia():
    File "wmi.py", line 850, in __getattr__
    return getattr (self._namespac e, attribute)
    File "C:\Python24\li b\site-packages\win32c om\client\dynam ic.py", line 489,
    in __getattr__
    raise AttributeError, "%s.%s" % (self._username _, attr)
    AttributeError:
    winmgmts:{imper sonationLevel=i mpersonate,auth enticationLevel =default}//./roo
    t/cimv2.win32_Phy sicalMedia

    Any help is appreciated.
    Louis


  • Michel Claveau

    #2
    Re: WMI Help

    Hi!

    Win32_PhysicalM edia WMI class is available only on Windows 2003 or XP

    Then, swap Admin <=Normal_user

    --
    @-salutations

    Michel Claveau


    Comment

    • Michel Claveau

      #3
      Re: WMI Help

      Re!

      This script run on my XP :


      import win32com.client
      WMIS = win32com.client .GetObject(r"wi nmgmts:root\cim v2")
      objs = WMIS.ExecQuery( "select * from Win32_PhysicalM edia")
      for obj in objs:
      print obj.SerialNumbe r
      print obj.Tag
      print

      --
      @-salutations

      Michel Claveau


      Comment

      • 3c273

        #4
        Re: WMI Help

        "Michel Claveau" <mcPas.De.Spam@ mclaveauPas.De. Spam.comwrote in message
        news:mn.6c687d6 72f8e52a4.34209 @mclaveauPas.De .Spam.com...
        Re!
        >
        This script run on my XP :
        >
        >
        import win32com.client
        WMIS = win32com.client .GetObject(r"wi nmgmts:root\cim v2")
        objs = WMIS.ExecQuery( "select * from Win32_PhysicalM edia")
        for obj in objs:
        print obj.SerialNumbe r
        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 202020202020202 020202020??? Thanks again.
        Louis


        Comment

        • Tim Golden

          #5
          Re: WMI Help

          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_Physica lMedia():
          print item
          A couple of things:

          + As someone else has pointed out, Win32_PhysicalM edia
          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_PhysicalM edia)
          is case-sensitive. So you have to put c.Win32_Physica lMedia
          (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 202020202020202 020202020???
          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_Physica lMedia ():
          print item

          </code>

          Good luck with WMI

          TJG

          Comment

          • 3c273

            #6
            Re: WMI Help

            "Tim Golden" <mail@timgolden .me.ukwrote in message
            news:mailman.81 45.1152819606.2 7775.python-list@python.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_Physica lMedia():
            print item
            >
            A couple of things:
            >
            + As someone else has pointed out, Win32_PhysicalM edia
            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_PhysicalM edia)
            is case-sensitive. So you have to put c.Win32_Physica lMedia
            (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 202020202020202 020202020???
            >
            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_Physica lMedia ():
            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


            Comment

            Working...