C# code to run my installer.exe file in silent mode, in the background, [duplicate]
Asked Answered
S

1

6

I have this C# code:

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);

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.

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.

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??

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?

Please help.

Seltzer answered 17/12, 2013 at 22:34 Comment(2)
What product did you use to create the installer? Not that it should matter, but it might help someone reproduce it.Joachima
Did you think to create temp BAT file with this command in it C:\Users\...\Temp\MyInstaller_7.1.51.14.exe -s -v -qn and run that?Armenian
S
2

This is the correct answer:

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.

Seltzer answered 18/12, 2013 at 23:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.