How to programmatically find the installation location of an installed application in Windows

I want to find the installed installation location on MSI programmatically. The application does not make an entry in the "Set Location" in the delete key in the registry. Application does not populate the ARPINSTALLLOCATION property. (This is the same value that is indicated in the "Add or Remove Programs" section and is stored in the "Uninstall" section). However, the deletion still finds where it is located, and can delete it. Where is this information stored? Windows uses the cached MSI installer to uninstall the application, but Install Location is determined for the first time during installation, so this information is not part of the installer package.

+3
source share
2 answers

I assume that when you say "installation location", you really mean "which directory is the application's exe located in?" Otherwise, the question is controversial because MSI does not have to install an β€œapplication”. It can install a component that does not have an EXE. And he can install it through several directories ...

But this will most likely work:

Call MsiGetProductInfo to get ARPINSTALLLOCATION. You will need to know the "product name" as it is installed. as the first parameter. Call MsiEnumProducts to list all installed "products" if necessary.

+2
source

VBScript, WindowsInstaller.Installer COM:

Dim installer
Set installer = CreateObject("WindowsInstaller.Installer")
Dim productCode, productName
For Each productCode In installer.Products
    WScript.Echo "ProductCode: " & productCode
    WScript.Echo "ProductName: " & installer.ProductInfo(productCode, "ProductName")
    WScript.Echo "InstallLocation: " & installer.ProductInfo(productCode, "InstallLocation")
    WScript.Echo "LocalPackage: " & installer.ProductInfo(productCode, "LocalPackage")
Next

Installer http://msdn.microsoft.com/en-us/library/windows/desktop/aa369432 (v = vs .85).aspx #

+2

Source: https://habr.com/ru/post/1788930/


All Articles