Install custom program with no user interaction
I would like to create a program that can install a program that user select (user select installer from disk). I know how to run a executable file using Process class. But how to install a program without user inte开发者_Python百科raction (silent install)?
Your installers you plan to run, need to support silent installs. If they don't, you're going to have a difficult time
Luckily, most installers allow the same command line arguments as an MSI. Try running your installer as programName_installer.exe /?
and see if it give you a help popup.
Here is a list of MSI command line options. \qn
removes all UI interaction for it.
In addition when you run your process, you need to have these settings to make sure no console popup appears to the user:
ProcessStartInfo info = new ProcessStartInfo("programName_installer.exe", @"\qn");
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
info.UseShellExecute = false;
info.RedirectStandardError =
info.RedirectStandardOutput = true;
using (Process process = Process.Start(info))
{
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
int exitCode = process.ExitCode;
}
精彩评论