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 软件包
基础教程推荐
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
