System.Process.Start - 运行 msi 问题 [英] System.Process.Start - running msi problem

查看:27
本文介绍了System.Process.Start - 运行 msi 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在 vb 应用程序中使用 System.Process.Start("test.msi") 运行 msi 时,出现以下错误.

When i try to run a msi using System.Process.Start("test.msi") in a vb app i get the following error.

无法打开安装包.联系应用程序供应商...

The installation package could not be opened. Contact application vendor...

双击时 Msi 文件工作正常,尝试使用 System.Process.Start 文本文件和 exe 文件,它们工作正常,只有 msi 有问题

Msi file works fine when double clicked, tried System.Process.Start with text files and exe files and they work fine, problem only with msi

文件.运行远景.也试过 xp 但没有运气

files. Running vista. Also tried xp but no luck

谢谢

推荐答案

如果您的 msi 有 setup.exe,请运行它.否则,使用此代码:

If you have a setup.exe with your msi, run that instead. Otherwise, use this code:

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

(来自此处:MSI 不在 C# 中运行)

需要这样做的原因是,当您执行 System.Process.Start("file.txt") 时,它会起作用,因为它(某种程度上)调用了 notepad.exe %1 可用于文本文件,但 msiexec %1 不适用于 msi,因为 msiexec 具有必需参数(选项).

The reason for needing to do it this way is that when you do System.Process.Start("file.txt") it will work since it is (sort of) calling notepad.exe %1 which will work for a text file but msiexec %1 will not work for a msi, since msiexec has a required parameter (Option).

您可以通过在命令行上尝试 msiexec file.msi 来自己测试 - 它会给您这条有用的小消息:

You can test this yourself, by trying msiexec file.msi on the command line - it will give you this helpful little message:

这篇关于System.Process.Start - 运行 msi 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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