我无法在C#代码中正确调用msiexec.exe。 [英] I cannot call msiexec.exe correctly in C# code.

查看:350
本文介绍了我无法在C#代码中正确调用msiexec.exe。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Process process = new Process();
process.StartInfo.FileName = @"msiexec.exe"; 

process.StartInfo.Arguments = string.Format(@"/i E:\My Steup Files\Installer.msi");

process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
process.WaitForExit();





执行上面的代码时,会出现Windows Installer帮助窗口。

我认为参数是正确的,我不知道为什么它不能执行。

有谁知道原因?谢谢你的帮助!



when execute above code, the Windows Installer help window comes out.
I think the parameter is correct, I don't know why it cannot execute.
Does anyone know the reason? Thanks for your help!

推荐答案

嗨seshaliang,



你可以尝试一下

Process.Start(msiexec.exe);
Hi seshaliang,

you can try it
Process.Start("msiexec.exe");


对不起。我没有找到错误点,所以我的问题不是很清楚。

真正的原因是msi文件包含空格的路径,然后窗口安装程序帮助dailog弹出。

我认为它用空格分析参数。

示例:msiexec.exe / i E:\ 我的Steup文件 \ Installer.msi / qn

为路径添加引号是好。现在cmdLine是:msiexec.exe / iE:\ 我的Steup文件 \Installer.msi/ qn
I am sorry. I didn't find the error point so my question isn't very clear.
The real cause is the path of msi file contains space, then window installer help dailog pops up.
I think it analysises params by spaces.
example: msiexec.exe /i E:\My Steup Files\Installer.msi /qn
Add quotes for the path is OK. Now the cmdLine is: msiexec.exe /i "E:\My Steup Files\Installer.msi" /qn


//请尝试此代码:

流程流程=新流程();

流程.StartInfo.WorkingDirectory = @E:\ Source; //设置exe文件所在的工作目录。

process.StartInfo.FileName =msiexec.exe;



process.StartInfo.Arguments = string.Format(@/ i E:\ My Steup Files \Installer.msi); //传递参数的数量。



process.StartInfo.UseShellExecute = false;

process.StartInfo.CreateNoWindow = false;

process.Start();

process.WaitForExit();
//Please try this code:
Process process = new Process();
process .StartInfo.WorkingDirectory = @"E:\Source"; //sets the working directory in which the exe file resides.
process.StartInfo.FileName = "msiexec.exe";

process.StartInfo.Arguments = string.Format(@"/i E:\My Steup Files\Installer.msi"); //Pass the number of arguments.

process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = false;
process.Start();
process.WaitForExit();


这篇关于我无法在C#代码中正确调用msiexec.exe。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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