2

新手问题,让我尝试尽可能清楚地说明这一点。我有一个需要静默执行 msi 包的程序(多个,但这不是问题)

MSI 包包含在与我的程序位于同一目录的文件夹中。我暂时给它起了一个简单的名称“InstallFiles”。

我不热衷于使用完整的路径名,例如。C:\my program\another directory\another directory 等,因为它将被放在多台新旧 PC 上,在这种情况下驱动器号可能会更改。到目前为止,我有:

install.StartInfo.FileName = "msiexec";
install.StartInfo.Arguments = "/i F:\\InstallFiles\\JRE.msi";
install.Start();
install.WaitForExit();

但是,当它启动时,它只给我 Windows Installer 开关信息然后终止,我如何让它运行以及如何更改文件路径?

4

2 回答 2

2

与以下开关一起使用:

/q[n|b|r|f]

    Sets user interface level
    n - No UI
    b - Basic UI
    r - Reduced UI

检查http://msdn.microsoft.com/en-us/library/windows/desktop/aa367988%28v=vs.85%29.aspx了解详细的命令行选项。

于 2012-09-16T15:37:43.827 回答
1

.msi 文件的执行应该像 .exe 文件,这是你的答案:https ://stackoverflow.com/a/12436300/359170

使用以下代码启动应用程序:

Process.Start("yourfile.msi"); 

它不需要完整路径,它会将当前目录添加到您在那里编写的文件名中。

System.IO.Directory.GetCurrentDirectory();

获取当前执行的文件目录。你可以通过像这样只添加文件名来获取文件路径:

 string path = System.IO.Directory.GetCurrentDirectory() + "\\yourfile.msi";
于 2012-09-16T15:36:22.980 回答