Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3946580
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:09:00+00:00 2026-05-20T01:09:00+00:00

I’ve run into a sticky problem using WMI (via win32com) in Python under Windows

  • 0

I’ve run into a sticky problem using WMI (via win32com) in Python under Windows 7. I haven’t been able to find a resolution for this.

Here is my code:

from win32com.client import GetObject

def get_printers(computer):
    """ Get a list of printers from the specified computer name. """
    wmiservice = GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\" + computer + r"\root\cimv2")
    return wmiservice.ExecQuery("Select * from Win32_Printer")

for printer in get_printers("ps2"):
    print printer.Name

This works great under Windows XP. But fails miserably if I run this under Windows 7:

Traceback (most recent call last):
  File "C:\Python27\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Python27\sample\temp2.py", line 8, in <module>
    for printer in get_printers("ps2"):
  File "C:\Python27\sample\temp2.py", line 5, in get_printers
    wmiservice = GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\" + computer + r"\root\cimv2")
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 72, in GetObject
    return Moniker(Pathname, clsctx)
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 87, in Moniker
    moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname)
com_error: (-2147024891, 'Access is denied.', None, None)

I tried everything I can think of in Win 7: disabled firewall (no virus scanner), ensured DCOM is enabled, ensured WMI is enabled, and disabled UAC. Any help would be greately appreciated.

Note: I’m using Python 2.7.1 with pywin32 build 215, under Windows 7 Ultimate x86 (and Windows XP SP3).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:09:01+00:00Added an answer on May 20, 2026 at 1:09 am

    As it turns out, the problem was not related to DCOM/WMI/UAC/Firewall. What was really suprising was that the Win 7 PC had nothing reported in it’s event log at all when these failures happened.

    What I noticed was that, as in the original problem, outgoing connections from Win 7 reported Access Denied. But I also noticed that connections incoming to the Win 7 PC (same python script as above) reported the RPC Server as being unavailable. Other PC’s (not the Win 7) PC would also report a kerberos error (ID 4) in the event log.

    The problem turned out that there was something funky with active directory on our domain, specifically with this Win 7 PC. For some reason active directory incorrectly thought there were multiple PCs with this name – this is the source of the kerberos event log.

    The fix that worked was: taking the Win 7 PC off the domain, changing the PC to a new name, then putting the PC back on the domain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.