[python-win32] Unreliable results with Winreg & WMI

Ben bba at inbox.com
Wed Feb 25 16:29:25 CET 2009


Hello

I have generally been getting better results using winreg than using WMI, but even Winreg (or config problems on our server) are causing me problems.  For example I'd use this code to find out if a certain security update is installed across all our servers:

def KB958644(OS, servername):
   HKLM_remote = _winreg.ConnectRegistry (r"\\%s" % servername, _winreg.HKEY_LOCAL_MACHINE)
   KEY_PATH = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\KB958644"
   ValueName = 'InstallDate'
   hKeyRemote = _winreg.OpenKey (HKLM_remote, KEY_PATH, 0, _winreg.KEY_READ)
   value, type = _winreg.QueryValueEx (hKeyRemote, ValueName)
   print 'KB958644: ', value
   return value 


Now on some servers, this works, and returns the date when the update was installed.  But on others it would return:
WindowsError: [Error 2] The system cannot find the file specified

When I look at the servers where it failed, I find the patch is installed and the registry key the script was looking for is there.   It is all Server 2003 on the same domain.  What could the problem be?

Thanks

____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails


More information about the python-win32 mailing list