C# - 执行进一步调用 msi 文件的 exe 文件

C# - Executing a exe file which further invokes a msi file

我有一个检查系统架构的.exe文件,根据系统架构调用相应的msi文件。

我正在尝试使用下面的代码从 C# 运行 这个 exe 文件

Process process = new Process();
process.StartInfo.FileName = "my.exe";
process.StartInfo.Arguments = "/quiet";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.WorkingDirectory = "path//to//exe//directory";
Console.WriteLine(process.StartInfo.WorkingDirectory);
process.Start();
process.WaitForExit();

正在调用 exe。我可以看到应用程序日志并且日志中没有错误。

但是 msi 没有启动或安装。 当我尝试 运行 手动安装相同的 exe 文件时,安装了 msi。

注意:此my.exe还有其他依赖文件放在同一目录中。

为什么我无法从 C# 程序安装 msi,而我可以手动安装。

我运行在管理员模式下安装 VisualStudios。

您需要以管理员身份执行 .exe(和 msi)。

为确保这一点,请使用:

process.StartInfo.Verb = "runas"

此外,尝试删除无提示参数以查看任何可能的错误。

"my.exe" 如果你调用 MSI,是否正在安装它,不是吗?

我在添加 Thread.Sleep() 后解决了这个问题。在 "process.WaitForExit()"

之前