Impersonating a Different Logon

Tim Golden mail at
Tue Apr 6 22:11:12 CEST 2010

On 06/04/2010 20:26, Kevin Holleran wrote:
> Hello,
> I am sweeping some of our networks to find devices.  When I find a
> device I try to connect to the registry using _winreg and then query a
> specific key that I am interested in.  This works great for machines
> that are on our domain, but there are left over machines that are
> stand alone and the credentials fail.  I understand you cannot pass in
> credentials with _winreg but is there a way to simulate a logon of
> another user (the machine's local admin) to query the registry?

The simplest may well be to use WMI (example from here):

<code - untested>
import wmi

reg = wmi.WMI (

result, names = reg.EnumKey (
for name in names:
   print name


I can't try it out at the moment but in principle it should work.


More information about the Python-list mailing list