0

Whenever we install a software, Windows OS will keep a backup copy of installer *.msi at C:\Windows\Installer\ location.

So I am iterating through all the msi file present at "C:\Windows\Installer\"

I want to prepare a mapping list where list will have *.msi file and its default location.

Let say C:\Windows\Installer[some product key]\123xR23.msi Consider "123xR23.msi" is backup file for WinZip installation. And installer has install WinZip at location "C:\Program Files(x86)\WinZip"

So list will have following entry "123xR23.msi","C:\Program Files(x86)\WinZip"

Please help me.

Thanks

Wrox
  • 53
  • 11
  • you can find backup .msi but you cannot find either that is installed or not... for example backup msi file name ABC.msi but installer install that as XYZ.msi because user change path as well installation directory as well exe name... so it is impossible to find perfect location –  Apr 26 '16 at 12:58
  • Hi Pranav right we can not know the exact path user has given at the time of installation. So I just to want to know the prediction in case if user has not change default values. – Wrox Apr 26 '16 at 13:02
  • if you want to predict then use installer name and find in program files folder and try to match the same –  Apr 26 '16 at 13:25
  • thank you for reply. Location "C:\Windows\Installer" has msi with random names. Even after reading *.msi using utility Orca.exe it is ambiguous. Take 3 to 5 *.msi and try to see it. In some case you will find path from msi database's "CustomActions" table, using query "SELECT Target FROM CustomAction WHERE Action = 'DIRCA_TARGETDIR'". – Wrox Apr 27 '16 at 04:27

1 Answers1

0

First off, why do you even need this?

There is a mapping of these *.msi files already in existence in the registry at HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\\Products\\InstallerProperties then the value of the msi is under LocalPackage

The S-1-5-18 is the Security ID of Local System.

The ProductGUID is also a bit weird here. In your installer you will see something like

2F7DBBE6-8EBC-495C-9041-46A772F4E311

but the product GUID in the registry path will look like this

6EBBD7F2CBE8C5940914647A274F3E11

There's definitely a reason for this but I don't know what it is. You'll just have to transform your product guid to this other representation when looking in the registry.

There is also a registry key called InstallLocation which should contain the install location of the msi package. This isn't always filled in though. Perhaps the install directory is stored somewhere else in the registry I don't know you'll have to look around probably.


Edit: Looks like each component of the install gets an entry by GUID in the registry as well which contains the path it was installed to. This could help you find the install location of a specific MSI if it is not listed under InstallLocation mentioned above. Per Micheal's comment, I would suggest taking advantage of the Msi related functions (https://msdn.microsoft.com/en-us/library/windows/desktop/aa372420(v=vs.85).aspx)

Brian Sutherland
  • 4,698
  • 14
  • 16
  • You are right. I have list of software and uninstaller location / uninstaller path from registry. I want to predict what software installed where if suppose user installed it with default settings. for example probable location of WinZip software installation will be "C:\Program File\WinZip" or "C:\Program File(86)\WinZip" I want to list down all the software and its probable installation path from .msi. (For that We can query or read *.msi using Orca.) I am not able to predict it from there. – Wrox Apr 27 '16 at 04:19
  • Why go compacting GUIDs and trawling through the registry when there are perfectly good ways to do this enumeration with C++ (see MsiEnumProducts/Ex and MsiGetProductInfo) or [C#](http://stackoverflow.com/questions/3526449/how-to-get-a-list-of-installed-software-products)? – Michael Urman Apr 27 '16 at 12:00
  • @Micheal Because I didn't know those methods exist =] It makes sense there's some windows api to discover this stuff. Consider writing an answer if you think it's the best solution to this problem. – Brian Sutherland Apr 27 '16 at 14:20
  • @Micheal your code looks good. But somehow out of 103 installed products on one machine I get only 47 products mapped with path. Can you suggest how can we find remaining 66 product path. – Wrox Apr 29 '16 at 12:21
  • Reason for reading from registry is some products installer are coming as EXE and so using windows API it is not possible to read their information, – Wrox Apr 29 '16 at 12:31