[python-win32] unusual network load when querying a remote registry over wmi
Eli Sandler
Eli.Sandler at vanadium-soft.com
Thu Feb 4 11:48:30 CET 2010
Hi,
I have a curious problem. I use Tim Golden’s module for WMI, and I use the ‘StdRegProv’ to query a remote registry over WMI. I get an unusual network load for this procedure.
Using a packet capture, I saw that each new query contains all the previous ones.
Do I use the module in a wrong way?
Did anyone else encounter this problem?
Here is the code:
def _tt( server, user, password ):
import win32con
import win32com
import wmi
oDispatch = win32com.Dispatch("WbemScripting.SWbemLocator")
remote_connection = oDispatch.ConnectServer( server, 'root\\default', user, password, '', '', 0, None )
oReg = wmi._wmi_object( remote_connection.Get( 'StdRegProv' ) )
hive = win32con.HKEY_LOCAL_MACHINE
key = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
return_value = {}
result = oReg.EnumKey( hive, key )
if result[0] != 0:
print "Couldn't enumerate sub keys for:",key
return
subkeys = result[1]
for subkey in subkeys:
result = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayName" )
if result[0] != 0:
print "Error geting 'DisplayName' for:",key+'\\'+subkey
continue
name = result[1]
if name is not None and len(name) > 0:
result = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayVersion" )
if result[0] != 0:
ver = ""
else:
ver = result[1]
result = oReg.GetStringValue( hive, key+'\\'+subkey, "Publisher" )
if result[0] != 0:
pub = ""
else:
pub = result[1]
return_value[name] = (ver, pub)
return return_value
Thanks in advance.
--
Eliyahu Sandler
Software Engineer
Vanadium Software Ltd.
www.vanadium-soft.com <http://www.vanadium-soft.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100204/e9a1c011/attachment.htm>
More information about the python-win32
mailing list