Obtain KBs installed in Windows machines

I am new in this relevance language world and I am trying to get a propertie to check how many KBs have a Windows 7 machine Installed.

Recently I was using the following relevance:

keys whose (name of it contains “.KB” or name of it contains “KB” or
name of it starts with “KB”) of keys(
“HKEYLOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”;“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component
Based Servicing\Packages”;“HKEY_LOCAL_MACHINE
\Software\Microsoft\WindowsNT\CurrentVersion\Hotfix”) of (registry;
native registry)

I use “number of” at the beggining I can obtain the number of
registry keys, but I could observe that some of KB are repited. I would
like to know if you can help me.

Because I need over that result:

A: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_100_for_KB2943357~31bf3856ad364e35~amd646.1.1.3
A: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_101_for_KB2973351~31bf3856ad364e35~amd64
6.1.1.1
A: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_102_for_KB2750841~31bf3856ad364e35~amd646.1.1.3
A: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_103_for_KB3011780~31bf3856ad364e35~amd64
6.1.1.5
A:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component
Based
Servicing\Packages\Package_104_for_KB3011780~31bf3856ad364e35~amd64~~6.1.1.5

A:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component
Based
Servicing\Packages\Package_105_for_KB2871997~31bf3856ad364e35~amd64~~6.1.2.5

A:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component
Based
Servicing\Packages\Package_105_for_KB2992611~31bf3856ad364e35~amd64~~6.1.1.0

A:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component
Based
Servicing\Packages\Package_105_for_KB3003743~31bf3856ad364e35~amd64~~6.1.1.1

A:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component
Based
Servicing\Packages\Package_105_for_KB3011780~31bf3856ad364e35~amd64~~6.1.1.5

Only I would like to keep KB name and not all the registry key line.
and I would like to show once each KB. At the end if I introduce the
prefix “number of” I will get the exactly KB installed in the machine.

Note: not clear to me that this method is ideal for this information

Thanks in advance for your help.

I Just modified your code… are you looking for something like this…

preceding texts of firsts “~” of following texts of firsts “for_” of((keys whose (name of it contains “.KB” or name of it contains “KB” or name of it starts with “KB”) of keys( "HKEYLOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages";“HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Hotfix”) of (registry; native registry))as string)

For getting only unique values, use the below code…

unique values of preceding texts of firsts “~” of following texts of firsts “for_” of((keys whose (name of it contains “.KB” or name of it contains “KB” or name of it starts with “KB”) of keys( "HKEYLOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages";“HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Hotfix”) of (registry; native registry))as string)

2 Likes

Thank you very much It is very good, but only lack don’t see results like that

Q: unique values of preceding texts of firsts “~” of following texts of firsts “for_” of((keys whose (name of it contains “.KB” or name of it contains “KB” or name of it starts with “KB”)of keys( “HKEYLOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”;“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages”;“HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Hotfix”) of (registry; native registry))as string)
A: KB2249857
A: KB2249857_RTM
A: KB2284742
A: KB2284742_RTM
A: KB2305420
A: KB2305420_RTM

I thought to remove results with this character “_” but I am trying add at the query but really I fail to eliminate all results containing that character

I cleaned up the relevance, refactored it a bit, and added an IF/THEN/ELSE statement to remove the _RTM:

unique values of (if (it contains "_RTM") then (preceding texts of firsts "_RTM" of it) else it ) of preceding texts of firsts "~" of following texts of firsts "for_" of (name of it as trimmed string) of keys whose (name of it contains "KB") of keys ( "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages";"HKLM\Software\Microsoft\WindowsNT\CurrentVersion\Hotfix") of (x32 registries;x64 registries)

The following is what I recommend to check both registries on both x64 and x32 systems:

(x32 registries;x64 registries)

This will not cause all results to be duplicated on x32 systems, while (registry; native registry) will.

3 Likes

Just note the HKEYLOCAL_MACHINE typo there

Also are people aware of the shortcuts we allow? HKLM can be put in a string being used as a registry “key” so you could put the following to save bytes

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages
1 Like

Hi All

Frist , thank you very much for your help

I tryed with the last recommendation from James and the results appears like that

unique values of (if (it contains “RTM”) then (preceding texts of firsts “RTM” of it) else it ) of preceding texts of firsts “~” of following texts of firsts “for” of (name of it as trimmed string) of keys whose (name of it contains “KB”) of keys ( “HKEYLOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”;“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages”;“HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Hotfix”) of (x32 registries;x64 registries) as string
A: _KB2249857
A: KB2249857
A: _KB2284742
A: KB2284742
A: _KB2305420
A: KB2305420
A: _KB2388210
A: KB2388210
A: _KB2393802
A: KB2393802
A: _KB2447568
A: KB2447568
A: _KB2479943
A: _KB2479943_SP1
A: _KB2492386
A: _KB2492386_SP1
A: _KB2506014
A: _KB2506014_SP1
A: _KB2506212
A: _KB2506212_SP1
A: _KB2506928
A: _KB2506928_SP1
A: _KB2509553
A: _KB2509553_SP1
A: _KB2511455
A: _KB2511455_SP1

It seems still appear duplicates. Really what I want is for all those records that appear with the character “_” does not appear. With this action all KBXXXX_RTM and KBXXXX_SP1 will not appear.

Ok It seems with the last modification I can help

unique values of (if (it contains “_”) then (preceding texts of firsts “RTM” of it) else it ) of preceding texts of firsts “~” of following texts of firsts “for” of (name of it as trimmed string) of keys whose (name of it contains “KB”) of keys ( “HKEYLOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”;“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages”;“HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Hotfix”) of (x32 registries;x64 registries) as string

As you can see I take what I said James but I replaced “RMT” with “_” so I see no duplicates and I know the exact number of KBs having installed the machine including the start “number of”

number of (unique values of (if (it contains “_”) then (preceding texts of firsts “RTM” of it) else it ) of preceding texts of firsts “~” of following texts of firsts “for” of (name of it as trimmed string) of keys whose (name of it contains “KB”) of keys ( “HKEYLOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”;“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages”;“HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Hotfix”) of (x32 registries;x64 registries) as string)

It looks like perfect

1 Like

I missed that typo. I was copy and pasting. Good catch.

I updated my relevance, should be correct now.

You need to edit your posts, select the relevance, then click the preformatted text option to cause the relevance to show up in grey. If you do not do this, it will cause problems with how it is displayed, and it will be incorrect.

The pre formatted text option looks like this:

</>