If possible I want to be able to do a couple of methods for listing what the .MSI files in the C:\Windows\Installer folder are for.
I can use WSH (Windows Scripting Host) to create an object and then read the information but then you're tied to WSH which I'd rather not do.
Set objInstaller = CreateObject("WindowsInstaller.Installer")
objInstaller.SummaryInformation.Property(3)
Querying the Registry will actually provide you with that information and is stored in this location
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products
As an example this key stores the information for "Microsoft Silverlight"
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\D7314F9862C648A4DB8BE2A5B47BE100\InstallProperties
DisplayName = the product name
LocalPackage = path and file name for the .msi file associated to the program installation for reinstall or repair build.
In this case as an example it is listed for my computer as: c:\Windows\Installer\5da99.msi but is a random name for all computers.
So doing a direct listing I can get it to return that it found it. But at this point I'm not sure how to return the full registry path where it found it so that I can query the other 2 values in that location.
Code: Select all
for /f "tokens=2,*" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products" /f "Microsoft Silverlight" /s /e /d ') DO echo %%b
What I think I need is to somehow store the base key and the final key as variables in order to more effeciently use them.
BaseKey
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\
ProductKey
D7314F9862C648A4DB8BE2A5B47BE100
PropertiesKey
InstallProperties
BaseKey and PropertiesKey always remain the same but the ProductKey is unknown or different on all computers depending on what software is installed.
My objective is to either feed a specific .msi file name to the batch to find out what it's DisplayName is but preferred is to simply query all the subkeys and then print out to file the DisplayName and Location for all the .msi files.
Or if possible provide the batch file with the name of the product to look for and then have it find that .msi file
Example output
Microsoft Silverlight: c:\Windows\Installer\5da99.msi
Adobe® Content Viewer: C:\Windows\Installer\29024037.msi
MSXML 4.0 SP2 (KB954430): C:\Windows\Installer\26e09f2.msi
Would greatly appreciate the time and effort involved if someone can assist me in how to achieve this.
Thank you