`
private void button1_Click(object sender, EventArgs e)
{
if(checkBox1.Checked == true)
{
//samplep = Process.Start(@"run\msiexec.exe", "/norestart /i setup.msi");
// Part 1: use ProcessStartInfo class.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = @"E:\Test projects\desktop\dd\dd\Data\wrar521b1.exe"; //Enter the path to the setup file
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
// Part 2: set arguments.
startInfo.Arguments = "-f j -o \"" + e + "\" -z 1.0 -s y " + e;
try
{
// Part 3: start with the info we specified.
// ... Call WaitForExit.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
MessageBox.Show("Error", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
}
}
}
`我如何通过Windows窗体应用程序安装另一个应用程序?我想将已安装的应用程序附加到文件夹,将其命名为软件]
如果您具有要安装的应用程序的安装文件(.exe),则可以通过以下方式轻松完成:
// Part 1: use ProcessStartInfo class.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "filepath"; //Enter the path to the setup file
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
// Part 2: set arguments.
startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2;
try
{
// Part 3: start with the info we specified.
// ... Call WaitForExit.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
此Google搜索可能会有用:如何静默运行exe C#