如何以编程方式查找 Windows 中已安装应用程序的安装位置

发布于 2024-10-14 19:55:24 字数 215 浏览 4 评论 0原文

我想以编程方式查找基于 MSI 的安装的安装位置。该应用程序不会在注册表的卸载项中记录安装位置。应用程序不填充 ARPINSTALLLOCATION 属性。 (这与“添加/删除程序”引用并存储在“卸载”密钥中的值相同)。但是卸载仍然可以找到它所在的位置并可以将其卸载。这些信息存储在哪里? Windows 使用缓存的 MSI 安装程序来卸载应用程序,但安装位置是在安装时首次确定的,因此此信息不是安装程序包的一部分。

I want to find the installed location for an MSI based installation programmatically. The app does not make an entry of Install Location in the uninstall key in the registry. Application does not populate ARPINSTALLLOCATION property. (This is the same value that is referred by Add/Remove Program and is stored in Uninstall key). However uninstall still finds where it is located and can uninstall it. Where is this information stored? Windows uses a cached MSI installer for uninstalling the application however Install Location is determined for the first time while installing so this information is not part of the installer package.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吻风 2024-10-21 19:55:24

我假设当您说“安装位置”时,您真正的意思是“应用程序的 EXE 位于哪个目录?”否则,这个问题是不明确的,因为 MSI 不一定必须安装“应用程序”。它可以安装没有 EXE 的组件。它可以跨多个目录安装它...

但这可能会起作用:

调用 MsiGetProductInfo 获取 ARPINSTALLLOCATION。您需要知道安装时的“产品名称”。 to 作为第一个参数。调用 MsiEnumProducts 枚举所有已安装的“产品”(如果需要)

I assume when you say "install location", you really mean "what directory is the EXE of the application located at?" Otherwise, the question is ambiguous because an MSI doesn't necessarily have to install an "application". It could install a component that has no EXE. And it can install it across multiple directories...

But this will likely work:

Call MsiGetProductInfo to get the ARPINSTALLLOCATION. You will need to know the "product name" as it is installed by. to as the first param. Call MsiEnumProducts to enumerate all the installed "products" if needed

情栀口红 2024-10-21 19:55:24

下面是使用 WindowsInstaller.Installer COM 接口的 VBScript 版本:

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

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

Here's a VBScript version that uses the WindowsInstaller.Installer COM interface:

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

Find out more about the Installer object from http://msdn.microsoft.com/en-us/library/windows/desktop/aa369432(v=vs.85).aspx#methods

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文