已安装软件的版本

时间:2015-07-13 09:32:38

标签: vbscript

我需要找到我机器上安装的软件版本。这样做的代码是

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE 
strComputer = "." 
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" 
strkey1= "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName" 
strEntry1b = "QuietDisplayName" 
strEntry3 = "VersionMajor" 
strEntry4 = "VersionMinor" 

'to get result in tabular format in html
strResult = "<body><table border=1 cellpadding=5 style=margin-left:50px;><tr><th>Sl No.</th><th>Softwares</th><th>Version</th></tr>"
Dim cnt
cnt=0

'getting the list from win32:_64 bit installed softwares
Set objReg = GetObject("winmgmts://" & strComputer & _
"/root/default:StdRegProv") 
objReg.EnumKey HKLM, strKey, arrSubkeys 

For Each strSubkey In arrSubkeys 
    intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _ 
    strEntry1a, strValue1) 
    If intRet1 <> 0 Then 
        objReg.GetStringValue HKLM, strKey & strSubkey, _ 
        strEntry1b, strValue1 
    End If 
    objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry3, intValue3 
    objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry4, intValue4 
    If strValue1 <> "" Then 
        'to check the duplicates
        If InStr(strResult,strValue1 & VbCrLf & "</td>")=0 Then
            cnt=cnt+1
            strResult = strResult & "<tr><td>"&cnt & "</td><td>" & strValue1 & VbCrLf & "</td><td>" &intValue3 & "." &intValue4 & "</td></tr>"
        End If
    End If 
Next 

但问题是它没有提供完整版本的软件。 例如:对于vlc 2.7.1,它不打印任何东西,而对于其他打印它的一半,即8.1而不是8.1.61001。如何打印完整版。

1 个答案:

答案 0 :(得分:1)

阅读DisplayVersion字符串,而不是DWORD值VersionMajorVersionMinor

objReg.GetStringValue HKLM, strKey & strSubkey, "DisplayVersion", version
相关问题