Programmatically installing MSI packages(以编程方式安装 MSI 软件包)
问题描述
我想从我的 C# .NET 应用程序中以编程方式安装给定的 .msi 包,最好使用我的应用程序指定的安装参数(如安装路径、拒绝垃圾软件等).
I would like to install a given .msi package programmatically from my C# .NET application, preferably with the installation parameters that my application specifies (like the installation path, decline crapware, etc.).
我进行了一些搜索,但我并没有真正找到任何有用的东西.最有希望的是这个主题,但我找不到任何Microsoft.Deployment.WindowsInstaller
或 WindowsInstaller.Installer
的那个.
I did some searches, but I haven't really found anything useful. The most promising hit was this topic, but I cannot find any documentation of Microsoft.Deployment.WindowsInstaller
or of WindowsInstaller.Installer
for that matter.
推荐答案
我发现上面提到的 Deployment Tools Foundation 项目是从 .NET 实现此目的的可靠方法.引用 Microsoft.Deployment.WindowsInstaller.dll 后,使用如下代码安装包:
I find the Deployment Tools Foundation project mentioned above to be a solid way to do this from .NET. Having referenced Microsoft.Deployment.WindowsInstaller.dll, use code like this to install a package:
Installer.SetInternalUI(InstallUIOptions.Silent);
Installer.InstallProduct(msiFilename, "ACTION=INSTALL ALLUSERS=2 MSIINSTALLPERUSER=");
.NET 包装器的文档位于 Program Files 的 Windows Installer XML 安装目录中的 .chm 文件中.该 DLL 的某些部分松散地包装了本机 Windows API,因此文档 here 也很有用,这就是我如何计算出上述代码段中的字符串以适应我的情况.
The documentation for the .NET wrapper is in a .chm file in the Windows Installer XML installation directory in Program Files. Some parts of that DLL loosely wrap the native Windows APIs so the documentation here can be useful as well, which is how I worked out the string in the above snippet to suit my situation.
这篇关于以编程方式安装 MSI 软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:以编程方式安装 MSI 软件包


- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 输入按键事件处理程序 2022-01-01