<div class="gmail_quote">On Fri, Aug 7, 2009 at 10:46 AM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Kevin Holleran wrote:<div class="im"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
On Fri, Aug 7, 2009 at 10:11 AM, MRAB <<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a> <mailto:<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a>>> wrote:<br>

<br>
    Kevin Holleran wrote:<br>
<br>
        Good morning,<br>
<br>
        I fear the answer to this is that I just cannot do this....<br>
<br>
        I wrote a python script that goes out to a bunch of remote<br>
        machines and queries the registry for some values.  Effectively,<br>
        there have been some software upgrades that have been done as<br>
        the need arose but we need to do them across the organization<br>
        now.  There are three, and the script checks all three and<br>
        returns the values.  One of these just needs to be a registry<br>
        change as it is a client server application that the server was<br>
        upgraded and the clients need a change to a registry value to work.<br>
<br>
        Long story short, I am using _winreg to do this.<br>
<br>
        hKey = _winreg.OpenKey (keyPath, path, 0, _winreg.KEY_SET_VALUE)<br>
        value,type = _winreg.QueryValueEx(hKey, item)<br>
        if (value == wrongValue):<br>
              _winreg.SetValue(hKey,'',_winreg.REG_SZ,correctValue)<br>
           <br>
</blockquote></div>
Hmm. If you're querying with (hKey, item), shouldn't you also be setting<br>
with (hKey, item), not (hKey,'')?<div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
        When I do this I receive the error:<br>
<br>
        _winreg.SetValue WindowsError: [Error 5] Access Denied<br>
<br>
<br>
        I am running this from my machine as a domain admin, connecting<br>
        to the remote machine which is also on the domain.<br>
        I am connecting to the remote registry with:<br>
<br>
        keyPath = _winreg.ConnectRegistry(r"\\" +<br>
        ipAddress,_winreg.HKEY_LOCAL_MACHINE)<br>
<br>
<br>
        Thanks for any help.<br>
<br>
    What is 'ipAddress'? Is it an actual IP address? The documentation says<br>
    it should be the computer name.<br>
    --     <a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br>
<br>
<br>
Thanks for the response.  From my experience that does not matter.  It is an actual IP address.  I can connect to the registry fine, its just the writing.  I read that value and other values.  It errors on the _winreg.KEY_SET_VALUE.  I am wondering if Windows just will not let the registry be changed remotely in this way or if there is something else I have to do.<br>

<br>
</blockquote>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>Sorry, that line is correct, I was removing specific information relevant to our infrastructure.  That is the valuename.  The error I am getting is:<br><br><br>Traceback (most recent call last):<br>
  File "script.py", line 53, in <module><br>    value,type = _winreg.QueryValueEx(hKey,item)<br>WindowsError: [Error 5] Access is denied<br><br>But the real error is here I believe:<br><br>
        hKey = _winreg.OpenKey (keyPath, path, 0, _winreg.KEY_SET_VALUE)<br><br>When I just do a:<br><br>
        hKey = _winreg.OpenKey (keyPath, path, 0, _winreg.KEY_READ)<br><br>I receive no errors.<br><br>Thanks.<br>