I am working on C# console application. It has only single requirement. It should silently install .exe setup files. These setup file are generated from InstallShield or other product. I do not generate any setup file. I tried to install Notepad++ using this code as well but it is not wokring.
To be more specific and to avoid duplicate mark to this question, I already referred many links regarding same. Some of them are
- http://www.c-sharpcorner.com/article/silent-installation-of-applications-using-c-sharp/
- C# code to run my installer.exe file in silent mode, in the background,
- How to run silent installer in C#
Code I tried:
OPTION-1
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);
OPTION-2
executableFilePath
is path to .exe setup file.
public static void DeployApplications(string executableFilePath)
{
PowerShell powerShell = null;
Console.WriteLine(" ");
Console.WriteLine("Deploying application...");
try
{
using (powerShell = PowerShell.Create())
{
powerShell.AddScript("$setup=Start-Process '" + executableFilePath + "' -ArgumentList '/s /v /qn /min' -Wait -PassThru");
Collection<PSObject> PSOutput = powerShell.Invoke();
foreach (PSObject outputItem in PSOutput)
{
if (outputItem != null)
{
Console.WriteLine(outputItem.BaseObject.GetType().FullName);
Console.WriteLine(outputItem.BaseObject.ToString() + "\n");
}
}
if (powerShell.Streams.Error.Count > 0)
{
string temp = powerShell.Streams.Error.First().ToString();
Console.WriteLine("Error: {0}", temp);
}
else
Console.WriteLine("Installation has completed successfully.");
}
}
catch (Exception ex)
{
Console.WriteLine("Error occured: {0}", ex.InnerException);
}
finally
{
if (powerShell != null)
powerShell.Dispose();
}
}
Both OPTION-1 and OPTION-2 open setup wizard UI. There is no installtion process starts and no application gets installed on computer. There is no error while executing this code.
QUESTIONS
- Am I missing anything in OPTION-1/2?
- What is wrong with the code above?
- Do I need to make any specialize InstallShield Wizard to skip UI from this console application?
- Why is it not working even with third party applications (e.g. notepad++) ?
- How to avoid administration permission UI as well?
OUTPUT I WANT
Console application must install .exe files silently. Setup wizard UI must be skipped. It is fine if console window appears. I do not want any UI to be appear other than console window.