开发者

Python Script to enumerate registry

from  _winreg import *
areg=ConnectRegistry(None,HKEY_LOCAL_MACHINE)
akey=OpenKey(areg,r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
count=0

for i in range (1024):
    try:
        subkey=EnumKey(akey,i)
        asubkey = OpenKey(akey, subkey)
        """print subkey"""


        val=QueryValueEx(asubkey,"DisplayName")
        list1.append(val[0])
        if(len(val[0])==0):
            pass
   开发者_StackOverflow     else:
            val2=QueryValueEx(asubkey,"DisplayVersion")       
            if(val2==""):
                list2.append("None")
                list3.append("None")
                continue

            else:
                list2.append(val2[0])
                val3=QueryValueEx(asubkey,"Publisher")                
                if(val3==""):
                    list3.append("None")

                else:
                    list3.append(val3[0])

print len(list1), len(list2), len(list3)

it takes the "DisplayName" "DisplayVersion" and "Publisher". The length of the lists doesnt match eventhough i have given "None" value to be entered if that value doenst exists.

And still this code doesnt enumerate all the contents of the "uninstall" subkey of registry.

Am i doing something wrong?

Thanks in advance.


    list1.append(val[0])
    if(len(val[0])==0):
        pass

Here you put a value in list1, but bail afterward. I have a hunch you meant to check and bail without actually adding anything to list1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜