Error when accessing remote registry

Tim Golden tim.golden at viacom-outdoor.co.uk
Wed Jun 18 04:16:54 EDT 2003


> c42 <nospam at nospam.net> wrote
> I'm using the following code to check the registry on a remote machine. 
> The code works fine when it hits a Windows 2000 Pro or 
> Windows XP Pro box, but crashes when it hits Windows NT4 workstation
> (WindowsError: [Errno 87] 

> -----------------------------
> Sample code:
> MachName = "TEST_1"
> aReg = ConnectRegistry(MachName,HKEY_LOCAL_MACHINE)        
> aKey = OpenKey(aReg, r"SOFTWARE\\Network Associates\\TVD\\Shared 
> Components\\On Access Scanner\\McShield\\Configuration") 
> -----------------------------

[snip error]

(btw, would be useful if you posted a piece of code 
 that could just be dropped into an editor and run;
 it took me at least three seconds to work out that
 I needed to do a [from _winreg import *] first :)

I don't have access to an NT4 machine here, but what
 jumps out at me at first is that you're doubling up
 the backslashes *within* a raw string. Is that intentional?
 It seems not to mind on my Win2k box (I tried it both
 ways) but maybe that's the problem.

Ahh. Just tried it on an NT server; it _is_ the doubled
 backslashes. Try changing your OpenKey line to:

aKey = OpenKey(aReg, r"SOFTWARE\Network Associates\TVD\Shared
Components\On Access Scanner\McShield\Configuration")

(blithely ignoring my own advice about posting
 runnable snippets. Oh well.)

TJG




More information about the Python-list mailing list