Impersonating a Different Logon

David Bolen at
Wed Apr 7 23:21:45 CEST 2010

Kevin Holleran <kdawg44 at> writes:

> Thanks, I was able to connect to the remote machine.  However, how do
> I query for a very specific key value?  I have to scan hundreds of
> machines and need want to reduce what I am querying.  I would like to
> be able to scan a very specific key and report on its value.

Any remote machine connection should automatically used any cached
credentials for that machine, since Windows always uses the same
credentials for a given target machine.

So if you were to access a share with the appropriate credentials,
using _winreg after that point should work.  I normally use
\\machine\ipc$ (even from the command line) which should always exist.

You can use the wrappers in the PyWin32 library (win32net) to access
and then release the share with NetUseAdd and NetUseDel.

Of course, the extra step of accessing the share might or might not be
any faster than WMI, but it would have a small advantage of not
needing WMI support on the target machine - though that may be a
non-issue nowadays.

-- David

More information about the Python-list mailing list