Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 845
Zolt Avatar asked Dec 17 '13 22:12

Zolt


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.


1 Answers

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.

like image 141
Zolt Avatar answered Oct 06 '22 00:10

Zolt