sni*_*ker 7 c# installation wmi windows-installer
我有一个应用程序,在整个公司的数百台计算机上使用,我必须修改应用程序的安装目录中的INI文件.用户可以随意安装应用程序,并且可以在任何给定时间安装多个版本的应用程序.我需要能够找到该安装目录.
到目前为止我考虑过的方法:
好吧,让我们听一下以编程方式确定Windows应用程序的安装目录的任何其他方法.
好吧,我想出了一个适合我的解决方案:
Type type = Type.GetTypeFromProgID("WindowsInstaller.Installer");
Installer msi = (Installer)Activator.CreateInstance(type);
foreach (string productcode in msi.Products)
{
string productname = msi.get_ProductInfo(productcode, "InstalledProductName");
if (productname.Contains("<APPLICATION NAME>"))
{
string installdir = msi.get_ProductInfo(productcode, "InstallLocation");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2583 次 |
| 最近记录: |