Remote Win32 Registry confusion?

Discussion in 'Python' started by benjamin schollnick, Oct 25, 2003.

  1. 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
    benjamin schollnick, Oct 25, 2003
    #1
    1. Advertising

  2. benjamin schollnick <> wrote in
    news:251020030643384444%:

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


    I've only done this once, a long time ago, and the ability has been severly
    limited since then by an MS service pack (you should have seen the security
    admin's face when I changed his path variable remotely without a trace ;-)

    > 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)


    You'll at least need to log in to the domain to get your security token,
    then use that to impersonate that user.

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


    Verify that this isn't turned off by either that machine or a group policy.

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


    key entry == value(?)

    -- bjorn
    Bjorn Pettersen, Oct 25, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HK
    Replies:
    1
    Views:
    3,605
    Cowboy \(Gregory A. Beamer\)
    Apr 1, 2004
  2. Replies:
    0
    Views:
    733
  3. Leny
    Replies:
    3
    Views:
    16,904
    Daniel
    Feb 1, 2005
  4. QyRoN
    Replies:
    2
    Views:
    402
    Larry Bates
    Aug 20, 2004
  5. Collin Miller
    Replies:
    10
    Views:
    580
    Roger Pack
    Jul 9, 2010
Loading...

Share This Page