I have the following C# code:
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Process.Start("cmd.exe", "/c" + desktopPath + "\\" + "MyInstaller_7.1.51.14.exe –s –v –qn");
The first line gets the path of my desktop where the .exe is located. The string desktopPath
is used in the second line.
The second line is supposed to start the installer in silent mode, so that the process runs in the background and the installation wizard does NOT appear at all. Running the string result of desktopPath + "\\" + "MyInstaller_7.1.51.14.exe –s –v –qn"
in the command prompt works just fine, and the installer runs in silent mode. In case anyone is wondering, the string result of
desktopPath + "\\" + "MyInstaller_7.1.51.14.exe –s –v –qn"
is
C:\Users\ME\Desktop\MyInstaller_7.1.51.14.exe -s -v -qn
and running this in the command prompt runs the installation in silent mode.
Unfortunately, triggering the same command in C# code as this:
Process.Start("cmd.exe", "/c" + desktopPath + "\\" + "MyInstaller_7.1.51.14.exe –s –v –qn");
does not run the installer in silent mode. Instead, the wizard comes up, visible to the user.
Does anyone know how I can modify this:
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Process.Start("cmd.exe", "/c" + desktopPath + "\\" + "MyInstaller_7.1.51.14.exe –s –v –qn");
so that the installer actually runs in silent mode, without the installer UI showing??
SIDE NOTE: –s –v –qn are switches for running in silent mode.
Try this, it works for me:
ProcessStartInfo psi = new ProcessStartInfo();
psi.Arguments = "–s –v –qn";
psi.CreateNoWindow = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.FileName = "MyInstaller_7.1.51.14.exe";
Process.Start(psi);
I don't know if the arguments you provided tried to hide the window, but perhaps like this, part of it won't be neccesary anymore.
Note that I used "notepad.exe" for my tests which were successful. Perhaps your installer reacts differently.
Try running the installer directly:
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string installerPath = Path.Combine(desktopPath, "MyInstaller_7.1.51.14.exe");
Process.Start(installerPath, "–s –v –qn");
来源:https://stackoverflow.com/questions/20643100/how-to-run-silent-installer-in-c-sharp