Re: How to retrieve "software updates" with WMI ?
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 01/27/05
- Next message: Gerry Hickman: "Re: Win32_scheduledjob, how to add user/pass to the job"
- Previous message: paisher: "Re: Win32_scheduledjob, how to add user/pass to the job"
- In reply to: Liviu Anca: "Re: How to retrieve "software updates" with WMI ?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 28 Jan 2005 00:43:33 +0100
Liviu Anca wrote:
> Hi Torgeir,
>
> Thank you for your detailed reply. However, this is not what I meant. Maybe
> I was not clear enough, I try now to be more specific. Here are the steps:
>
> - installed WinXP with SP1 (with Windows Media Player 8 included)
> - updated Windows Media Player (to version 10) through WindowsUpdate site
> - installed SP2
>
> In this situation, when "Show updates" is checked in Add/Remove Programs, I
> am able to see under "Windows Updates" the following items:
> - Windows Media Player 10
> - Windows Media Format Runtime
>
> Please let me know if it is possible to retrieve this information using WMI
> and which class should I use. Win32_Product and Win32_QuickFixEngineering do
> not seem useful here.
> I know that an alternative way may be to directly read from registry under
> "...Uninstall" key, but I'm trying to get to a WMI solution now.
Hi
Looking for the registry value "ParentKeyName" under the
"...Uninstall" key looks like the only way to obtain it.
Here is a script that uses WMI's StdRegProv to do the job:
'--------------------8<----------------------
sComputer = "." ' use . for local computer
sAppsList = UpdatesInARP(sComputer)
For Each sAppName In Split(sAppsList, vbCrLf)
If sAppName <> "" Then
WScript.Echo sAppName
End If
Next
Function UpdatesInARP(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
sValue = ""
iRC = oRegistry.GetStringValue( _
HKLM, sBaseKey & sKey, "ParentKeyName", sPKNValue)
If iRC = 0 Then
If sPKNValue <> "" Then
iRC = oRegistry.GetStringValue( _
HKLM, sBaseKey & sKey, "DisplayName", sValue)
If iRC <> 0 Then
oRegistry.GetStringValue _
HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
End If
End If
End If
If sValue <> "" Then
UpdatesInARP = _
UpdatesInARP & sValue & vbCrLf
End If
Next
End Function
'--------------------8<----------------------
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
- Next message: Gerry Hickman: "Re: Win32_scheduledjob, how to add user/pass to the job"
- Previous message: paisher: "Re: Win32_scheduledjob, how to add user/pass to the job"
- In reply to: Liviu Anca: "Re: How to retrieve "software updates" with WMI ?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|