Is there a way to programmatically turn on remote registry?

Tim Golden mail at timgolden.me.uk
Tue Oct 23 04:07:46 EDT 2012


On 22/10/2012 21:01, Kevin Holleran wrote:
> Tim,
> 
> I am looking here:
> 
> SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BF9F6FB0-C999-4D19-BED0-144F77E2A9D6}
> 
> Enumerating the keys for a BusType == 5, then grabbing the values of
> DriverDesc, DriverDate, & DriverVersion.
> 
> So I am doing this:

[... snip querying uninstallers ...]

I don't have that particular uninstaller key but the code below, using
the wmi module to hide the plumbing, queries all the installers and
should give you enough of an idea, hopefully. For brevilty, I've only
bothered with extracting string values; it would be easy to extract
other datatypes.

To perform the same query on another computer, just pass the other
computer name (or IP address) as the first parameter to the wmi.WMI call
(or use the named param "computer").

<code>
import _winreg as winreg
import wmi

HKLM = winreg.HKEY_LOCAL_MACHINE
UNINSTALLERS = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"

registry = wmi.WMI(namespace="default").StdRegProv
_, names = registry.EnumKey(HKLM, UNINSTALLERS)
for name in names:
    print name
    uninstaller = UNINSTALLERS + "\\" + name
    _, value_names, value_types = registry.EnumValues(HKLM, uninstaller)
    for value_name, value_type in zip(value_names, value_types):
        if value_type == winreg.REG_SZ:
            _, value = registry.GetStringValue(
              HKLM, uninstaller, value_name
            )
        else:
            value = "(Non-string value)"
        print u"  ", value_name, u"=>", value

</code>


TJG



More information about the Python-list mailing list