I am trying to figure out what are the differences between WUA (Windows Update Agent API) IupdateSearcher and wmic qfe list.
When I use WUA IupdateSearcher I get these updates:
(New-Object -ComObject Microsoft.Update.Session).CreateUpdateSearcher().Search('IsInstalled=1').Updates | Format-Table -AutoSize
And when using wmic qfe list:
wmic qfe list brief
The latter includes updates that the former doesn't and vice versa. Why is that?
For example, KB5007273 appears on wmic but doesn't appear on WUA
and vice versa, for example, KB4023057 appears on WUA but doesn't appear on wmic
This post (Windows Update Agents Vs WMIC QFE GET) from #RRUZ should get you started:
WMIC QFE GET command is equivalent to execute a query with the
Win32_QuickFixEngineering WMI class, since with Windows Vista, this
class returns only the updates supplied by Component Based Servicing,
in olders windows versions uses the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix
and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates registry keys to
enumerate the updates.
The IUpdateSearcher interface which is part of the Windows Update
Agent API (WUA), can be used to enumerate all the fixes including the
installed via the CBS, Updates supplied by Microsoft Windows Installer
(MSI) or the Windows update site, and so on.
And to get a deeper dive, check this article search for installed windows updates using Delphi, WMI and WUA shown in this post Windows API equivalent to "WMIC QFE Get" by #RRUZ:
WMI (Windows Management Instrumentation) using the
Win32_QuickFixEngineering class, you can retrieve a small system-wide
update, commonly referred to as a quick-fix engineering (QFE) update.
Starting with Windows Vista, the Win32_QuickFixEngineering class
returns only the updates supplied by Component Based Servicing (CBS),
so some updates are not listed.
WUA (Windows Update Agent) using the Windows Update Agent API is a
best option to retrieve the list of updates, you can access the
interfaces and objects from this API from delphi importing the
wuapi.dll file or creating a late-binding com object using the
Microsoft.Update.Session GUID. the next samples uses the late-binding
way.
Additionally for people searching for the way to get all installed updates in the system, which would work for a very wide range of Windows Server Versions (WS 2003 to WS2022 - PS 1.0 or higher) you will need to query both QFE and WUA updates. This might get you duplicate updates so you just got to parse those out.
Related
How can I get the patch informations from registry in win7 by windows API?
I want to get the "id + name + desc + date" of all patchs.
You can list the installed HotFixes using several ways:
Powershell:
Get-HotFix | select HotFixID, Description, InstalledOn
WMI:
wmic qfe get HotFixID,Description,InstalledOn
Both ways use the Win32_QuickFixEngineering WMI class to list Windows Updates, and only returns updates supplied by Component Based Servicing (CBS).
Updates supplied by the Microsoft Windows Installer (MSI) or the Windows update site are not returned by Get-Hotfix/Win32_QuickFixEngineering.
Therefore if you can use Windows Update API with powershell to list all updates:
$session = New-Object -ComObject Microsoft.Update.Session
$searcher = $Session.CreateUpdateSearcher()
$searcher.Search("IsInstalled=1").Updates | ft -a Date,Title,Description
Registry:
You can enumarate keys on this location HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages and then check the (string) value InstallClient for the "WindowsUpdateAgent".
You can enumerate the keys using the Windows API functions which deals with registry. Here's an example from MSDN.
The Windows Update API is the recommended way by Microsoft, so you better give it a try.
Occasionally, when we perform our maintenance cycle the domain controller will take too long and some of our virtual machines will default to the public network category instead of domain authenticated. After searching through BOL and Google, I found the Get-NetConnectionProfile cmdlet but it only seems to be available on Windows 2012 and later. We have some machines still running Windows 2008. I've already attempted to use the -CimSession switch to connect to a 2008 machine and it returned an error.
Is there a PowerShell equivalent for earlier versions of Windows?
The entire CIM cmdlet came out with Server 2012, and is representing this CimClass class which is a part of Windows Management Infrastructure(MI), also introduced in Server 2012. Which seems to be replacement of Windows Management Instrumentation(WMI), or in Microsoft's word:
The Windows Management Infrastructure (MI) features represent the
latest version of the Windows Management Instrumentation (WMI)
Thus is closest counter part you can get is Get-WMIObject cmdlet in eailer OS. The item you looking for, should be MSFT_NetConnectionProfile. Unfortunately I didn't find anything similar from get-wmiobject -list. I also checked documentation here Networking Device Classes without luck.
If you give get-wmiobject a shot, I don't expect it would return things exactly the same, but maybe some wmi object(s) would return the item you care most?
I am a newbie in C++ and currently working to get Windows Hotfix/Patch information in C++ DLL.
I have evaluated the following ways:
By executing a sub process in C++ code and running wmic qfe get and read all the data.
By using the C++ APIs to initialize COM, Connect to Wbem and execute select * from win32_quickfixengineering query.
Apart from above two methods,
Is there any direct Windows API that does all the job for me and gives the list of KB Info currently installed on the machine?
You can use the Windows Update Agent API and the IUpdateSearcher interface.
What's the simplest way to find out which version of Windows, and which service pack, is running on a computer with VBScript?
For example I'd want to know Windows XP and Service Pack 3.
An easy way of doing this is to use the WMI class Win32_OperatingSystem which has the properties ServicePackMajorVersion, ServicePackMinorVersion, Name and Version. You can find samples here: WMI Tasks: Operating Systems
The data you get back might not be in the exact format that you want though so you might need to have some kind of lookup table to make it look exactly right.
I am working on windows 7 support. In my application I want to gather installed updates and patches. Currently I am gathering it from WIn32_QuickFixEngineering. But it is not giving information for InstalledSDate , Description.
I need to get this either from registry or API (C++ application). In other operating system like XP, 2k3 registry keys are-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates
But these are not present on windows 7.
Can any one give thought on this..
I was also trying to figure out where the registry key for "Hotfix" had moved to.
I am setting up a debug symbol server on Windows 7. While I was following instructions from the book Debugging Applications for Microsoft ... Windows (by John Robbins), I was getting the error "Unable to enumerate the hot fix key" from a piece of vbscript code that Mr. Robbins recommends.
I realized that the vbs code is looking for the reg key SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix, which is not present on Windows 7.
While searching for a substitute key (or any other alternative), I found some helpful information here: http://forums.cnet.com/5208-12546_102-0.html?threadID=327588
The command shown on that cnet forum was a viable substitute in my case:
wmic qfe list full
shown at the cmd.exe prompt:
C:\Users\All Users>wmic qfe list full
Windows Update Agent API
Not sure if this is your issue: InstallOn properties for QFEs are sometimes stored as 64-bit, hexdecimal timestamps. To use this as a date:
Check first whether it is a hexadecimal value. If not, it is likely a regular date value.
Then, (in C#) use this to convert it to a DateTime:
DateTime.FromFileTimeUtc( Int64.Parse(<InstallOn>, System.Globalization.NumberStyles.AllowHexSpecifier));
try looking here:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages]