views:

289

answers:

1

I am having a very tough time achieving this one seemingly very simple goal...

I have to gather the value of a single registry key on several machines for the sake of auditing whether the machines scanned need to be patched with newer versions of software. I am only permitted to use python 3 as per our company policy (which is on drugs, but what can i do).

i have been looking into using the winreg module to connect to the remote machine (using credentials, we are on a domain) but I am confronted time and again with

TypeError: The object is not a PyHKEY object (or a number of other issues.)

this seems like a very common need and i've been surprised at the difficulty i have had finding any examples for python 3 that i can use to figure out what I'm doing wrong.

Any assistance that anyone would be kind enough to give would be greatly appreciated. Thanks in advance.

+1  A: 

Can you show the code which you are writing? Have you opened the key? Many people do get problems since they have not opened it? This is just a guess, hope it works

key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'SYSTEM\CurrentControlSet\Enum\Root')
Manish Sinha
You have to open the key first, even if you want to delete it. The error message comes from calling a winreg method with an object that is not a valid (i.e. opened) key handle.
Michael Dillon