本帖最后由 wgboy 于 2010-12-7 10:50 编辑
请大大们看看,这个要怎么更改
错误: 表达式错误
$oReg.EnumKey $hkey
~~~~~~~~~~~~~~^const $hkey = "&H80000002"
Const $REG_SZ = 1
softlist()
Func softlist()
;StdOut = WScript.StdOut
$host="."
$oReg=ObjGet("winmgmts:{impersonationLevel=impersonate}!\" &$host& "\root\default:StdRegProv")
$strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
$oReg.EnumKey $hkey, $strKeyPath, $arrSubKeys
;RegEnumKey($strroot&""&$strKeyPath,$arrSubKeys)
For $strSubKey In $arrSubKeys
If NotHotfix($strSubKey) Then
$SoftNameAndVersion = getProgNameAndVersion($oReg,$strKeyPath & "" & $strSubKey)
If $SoftNameAndVersion<>"0" Then
ConsoleWrite("软件"&$SoftNameAndVersion)
EndIf
EndIf
Next
EndFunc
Func NotHotfix($sSubKey)
If StringLeft($sSubkey,2) = "KB" And StringLen($sSubkey) = 8 Then
NotHotfix = 0
Else NotHotfix = 1
Endif
EndFunc
Func getProgNameAndVersion($oReg,$sKeyRoot)
Dim $sKeyValuesAry, $iKeyTypesAry, $nCnt, $sValue, $sDisplayName, $sDisplayVersion
$oReg.EnumValues $hkey, $sKeyRoot, $sKeyValuesAry, $iKeyTypesAry
If NOT IsArray($sKeyValuesAry) Then
getProgNameAndVersion = 0
Exit Func
EndIf
For $nCnt = 0 To UBound($sKeyValuesAry)
If StringInStr(1, $sKeyValuesAry($nCnt), "DisplayName") Then
If $iKeyTypesAry($nCnt) = $REG_SZ Then
$oReg.GetStringValue $hkey, $sKeyRoot, $sKeyValuesAry($nCnt), $sValue
If $sValue<>"" Then
$sDisplayName = $sValue
$sDisplayName = StringReplace($sDisplayName, "[", "(")
$sDisplayName = StringReplace($sDisplayName, "]", ")")
EndIf
EndIf
ElseIf StringInStr(1, $sKeyValuesAry($nCnt), "DisplayVersion") Then
If $iKeyTypesAry($nCnt) = $REG_SZ Then
$oReg.GetStringValue $hkey, $sKeyRoot, $sKeyValuesAry($nCnt), $sValue
If $sValue<>"" Then $sDisplayVersion = $sValue
EndIf
EndIf
If ($sDisplayName<>"") AND ($sDisplayVersion<>"") Then
getProgNameAndVersion = $sDisplayName & " --版本号: " & $sDisplayVersion
Exit Func
Else getProgNameAndVersion = 0
EndIf
Next
If $sDisplayName<>"" Then
getProgNameAndVersion = $sDisplayName
Exit Func
EndIf
EndFunc
|