Changing Remote Registry

Kevin Holleran kdawg44 at gmail.com
Mon Aug 10 08:47:19 EDT 2009


On Fri, Aug 7, 2009 at 2:08 PM, Tim Golden <mail at timgolden.me.uk> wrote:

> Kevin Holleran wrote:
>
>> Long story short, I am using _winreg to do this.
>>
>> hKey = _winreg.OpenKey (keyPath, path, 0, _winreg.KEY_SET_VALUE)
>> value,type = _winreg.QueryValueEx(hKey, item)
>> if (value == wrongValue):
>>       _winreg.SetValue(hKey,'',_winreg.REG_SZ,correctValue)
>>
>>
>> When I do this I receive the error:
>>
>> _winreg.SetValue WindowsError: [Error 5] Access Denied
>>
>
> As an alternative, try using WMI instead. You'll have to look up the docs
> a bit, but to get you started:
>
> <code>
> import wmi
>
> reg = wmi.WMI ("remote-machine", namespace="default").StdRegProv
>
> print reg.methods.keys ()
>
> </code>
>
> TJG
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


Thank you for your response.

I actually started with the WMI wrapper but isn't that just a wrapper that
utilizes (in this case) the _winreg module?

I guess my question is will Windows let me change the registry remotely?
The error is a Windows permission error on the KEY_SET_VALUE.  I am running
this as a domain admin on a machine on the domain.  Does the connection
inherit the credentials I am running it under or will I need to pass those
in?  Or does Windows simply not let me change the registry?

To me its not worth too much trouble.  If I can change it in place it saves
me just a little bit of work because I have to touch each machine anyway for
other reasons.  The big difference is that I can change all the machines I
have to touch right now and get them fixed up or these folks are just going
to have to wait until I get to each one.

Thanks for all your help and support.

Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090810/88264bb8/attachment-0001.html>


More information about the Python-list mailing list