I found out if running audit.vbs on a 64-Bit machine, collecting software from another 64-Bit Windows returns only 32-Bit Software - regardless of requesting the software/uninstall hive or the 6432 hive. To make audit.vbs run on 32 and 64 Bit systems and also list 32- and 64 Bit Software the script must be changed.
The following example lists 32 AND 64 Bit Software regardless of being run on a 32 or 64 Bit Machine. It must somehow replace the "installed Software" section in audit.vbs.
[code] strComputer = "." Const HKLM = &h80000002 Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet") objCtx.Add "__ProviderArchitecture", 32 objCtx.Add "__RequiredArchitecture", TRUE Set objLocator = CreateObject("Wbemscripting.SWbemLocator") Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx) Set objStdRegProv = objServices.Get("StdRegProv")
WScript.Echo "32-bit Applications" WScript.echo "-------------------"
Call GetApplications
objCtx.Add "__ProviderArchitecture", 64 objCtx.Add "__RequiredArchitecture", TRUE Set objLocator = CreateObject("Wbemscripting.SWbemLocator") Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx) Set objStdRegProv = objServices.Get("StdRegProv")
WScript.Echo "64-bit Applications" WScript.echo "-------------------"
Call GetApplications
Sub GetApplications
' Use ExecMethod to call the GetStringValue method Set Inparams = objStdRegProv.Methods_("EnumKey").Inparameters Inparams.Hdefkey = HKLM Inparams.Ssubkeyname = "Software\Microsoft\Windows\CurrentVersion\Uninstall\"
set Outparams = objStdRegProv.ExecMethod_("EnumKey", Inparams,,objCtx)
For Each strSubKey In Outparams.snames
Set Inparams = objStdRegProv.Methods_("GetStringValue").Inparameters Inparams.Hdefkey = HKLM Inparams.Ssubkeyname = "Software\Microsoft\Windows\CurrentVersion\Uninstall\" & strSubKey Inparams.Svaluename = "DisplayName" set Outparams = objStdRegProv.ExecMethod_("GetStringValue", Inparams,,objCtx)
if ("" & Outparams.sValue) = "" then 'wscript.echo strSubKey Else wscript.echo Outparams.SValue End iF
'Inparams.Svaluename = "QuietDisplayName" 'set Outparams = objStdRegProv.ExecMethod_("GetStringValue", Inparams,,objCtx) 'wscript.echo Outparams.SValue
Next
End Sub [/code]
|