MSI 不在 C# 中运行 [英] MSI doesn't run from within C#

查看:31
本文介绍了MSI 不在 C# 中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Proces.Start 方法从 C# 运行 MSI 文件.MSI 文件很好,因为我可以正常运行它,但是当我尝试在某些 C# 代码中运行 MSI 文件时,我收到以下错误.

I am trying to run an MSI file from C# using the Proces.Start method. The MSI file is fine, because I can run that normally, but when I try to run the MSI file within some C# code I receive the following error.

"此安装包无法被打开.验证包存在,并且您可以访问它,或者联系应用程序供应商验证这是一个有效的窗口安装包"

"This installation package could not be opened. Verify that the package exists, and that you can access it, or contact the application vendor to verify that this is a valid windows installer package"

下面是我用来运行 MSI 文件的代码...

Below is the code that I am using to run the MSI file...

Process p = Process.StartApplication.StartupPath  "/Packages/Name.msi");

p.WaitForExit();   

我该如何解决这个问题?

How can I fix this problem?

好的,我现在知道了.我只是将其更改为运行与 MSI 文件一起生成的 setup.exe 文件,而不是运行 MSI 文件...

OK, I got it now. I just changed it to run the setup.exe file that is generated with the MSI file, instead of the running the MSI file...

推荐答案

msi 文件无法单独运行.如果您双击它们,Windows 将启动

msi files cannot run on their own. If you double click on them, Windows will start

msiexec/i PathToYour.msi

您是否尝试明确这样做?

Did you try to do that explicitly?

示例:(@Webleeuw 提供)

Example: (Courtesy @Webleeuw)

Process p = new Process();
p.StartInfo.FileName = "msiexec";
p.StartInfo.Arguments = "/i PathToYour.msi";
p.Start();

这篇关于MSI 不在 C# 中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆