
Read the information in Control Panel - Add/Remove Programs
Quote:
> Is there a way to read out the entries in Add/Remove Programms (Control
> Panel) - to get the software inventory on Windows 2000
Hi
Here is a script that on a local or remote computer enumerates the Uninstall
part in registry using WMI (WMI comes default with WinME, Win2k and WinXP).
Run it with cscript.exe from a command prompt for a demo:
sComputerName = "." ' use "." for local computer
sInstApps = InstalledApplications(sComputerName)
' text block
WScript.Echo "As text block start..." & vbCrLf
WScript.Echo sInstApps
WScript.Echo "As text block stop..." & vbCrLf
' Convert to Array
aInstApps = Split(sInstApps, vbCrlf)
WScript.Echo "As array elements start..." & vbCrLf
For Each sApp In aInstApps
If sApp <> "" Then
WScript.Echo sApp
End If
Next
WScript.Echo "As array elements stop..." & vbCrLf
' alternatively
'For i = 0 To UBound(aInstApps)
' If aInstApps(i) <> "" Then
' WScript.Echo aInstApps(i)
' End If
'Next
Function InstalledApplications(node)
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oRegistry = _
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& node & "/root/default:StdRegProv")
sBaseKey = _
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)
For Each sKey In arSubKeys
iRC = oRegistry.GetStringValue( _
HKLM, sBaseKey & sKey, "DisplayName", sValue)
If iRC <> 0 Then
oRegistry.GetStringValue _
HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
End If
If sValue <> "" Then
InstalledApplications = _
InstalledApplications & sValue & vbCrLf
End If
Next
End Function
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter