Remote Win32 Registry confusion?

benjamin schollnick bscholln at mac.com
Sat Oct 25 06:43:38 EDT 2003


Folks,

I am having difficulty with *reading* the registry from a remote Windows
box...

1) I need to impersonate a different user name & password, then the
user I
am currently logged in as.
   (i.e. access the registry as a administrator)

2) The registry to be examined is on a different machine...

3) I just need the key entry returned....

For example
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DrWatson\AppendToLogFile
returning the value it has been saved with.

I by no means am a Win32 Python expert, but I usually can muddle my way
through....
But I am missing something here...  And I am not sure what...

I have proof of concept VBScript code....

   strroot = "HKEY_LOCAL_MACHINE"
   strKeyPath = "\SOFTWARE\Microsoft\DrWatson"
   strKey = "AppendToLogFile"
   
   Dim arrValues
   strKeyPath = "\SOFTWARE\Microsoft\DrWatson"
   strKey = "AppendToLogfile"
   objRegister.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strKey,
value
   
   Wscript.Echo value

Here's the code that I have attempted to use....  Can anyone point out
what
I am missing?

It works fine locally, but I can't figure out how to assign the user
account
and password for the remote system.

import _winreg
import win32com.client



host = "127.0.0.1"     # local host
key = _winreg.ConnectRegistry(host, _winreg.HKEY_LOCAL_MACHINE)
hkey = _winreg.OpenKey(key,
r"Software\Microsoft\Windows\CurrentVersion\Uninstall")
num = _winreg.QueryInfoKey(hkey)[0]
print "*** Found %d Software ***" % num

try:
    for x in range(1000):
        uninstall = _winreg.EnumKey(hkey, x)
        skey = _winreg.OpenKey(key,
"Software\Microsoft\Windows\CurrentVersion\Uninstall\%s" % uninstall)
        try:
            software = _winreg.QueryValueEx(skey, "DisplayName")[0]
            print "%s-%s" % (uninstall, software)
        except:
            pass
except:
    pass




More information about the Python-list mailing list