C#代码在后台以静默模式运行我的installer.exe文件, [英] C# code to run my installer.exe file in silent mode, in the background,

查看:462
本文介绍了C#代码在后台以静默模式运行我的installer.exe文件,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下C#代码:

string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
ProcessStartInfo psi = new ProcessStartInfo();
psi.Arguments = "–s –v –qn";
psi.CreateNoWindow = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.FileName = desktopPath + "\\" + "MyInstaller_7.1.51.14.exe";
Process.Start(psi);

第一行只是抓住了我的桌面的路径,其余的试图以静默方式运行安装程序exe文件.静默模式是指在后台没有安装向导,或者在安装过程中没有任何类型的UI.使用–s –v –qn参数,以便安装以静默方式运行.

The first line simply grabs the path of my desktop and the rest attempts to run an installer exe file in silent mode. By silent mode I mean, in the background, without the install wizard, or any UI of any sort during installation. The –s –v –qn arguments are there so that that the installation runs in silent mode.

问题是,当我在命令提示符下运行与以上命令等效的命令时,即为:

The problem is that when I run the command equivalent of the above in the command prompt, which is this:

C:\Users\ME\Desktop>MyInstaller_7.1.51.14.exe -s -v -qn

安装程序将以静默方式根据需要运行.

The installer runs as wanted, in silent mode.

不幸的是,问题在于,使用上述代码在C#中尝试相同的操作不会在静默模式下运行安装程序.出现安装向导,确实是 BAD .

Unfortunately, the problem is that trying the same thing in C# with the above code does NOT run the installer in silent mode. The installation wizard DOES appear, which is BAD for by purposes.

我在想,也许我需要像这样通过C#或在用户的0 id下运行该服务.或使用-i开关.我不太确定谁能帮忙?

I'm thinking maybe I need to run this like a service via C# or under the 0 id of the users. Or with an -i switch. I'm not really sure. Can anyone help??

为澄清起见,我的问题是,如何编写C#代码以在无可见UI的后台以静默模式运行我的installer.exe文件?

Just for clarification, my question is, how do I write C# code to run my installer.exe file in silent mode, in the background, with no visible UI?

请帮助.

推荐答案

这是正确的答案:

ProcessStartInfo psi = new ProcessStartInfo();
psi.Arguments = "/s /v /qn /min";
psi.CreateNoWindow = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.FileName = newRenamedFile;
psi.UseShellExecute = false;
Process.Start(psi);

问题在于交换机缺少正斜杠.

The issue was the switches were missing the forward slashes.

这篇关于C#代码在后台以静默模式运行我的installer.exe文件,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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