Process类详细介绍
1 //用msiexec.exe执行一个安装程序
2 string fileName = setupPath + "Installer.msi";
3 Process p = new Process();
4 p.StartInfo.FileName = "msiexec.exe";
5 p.StartInfo.Arguments = string.Format(" /i {0} /passive", fileName);
6 p.StartInfo.UseShellExecute = false;
7 p.StartInfo.RedirectStandardInput = true;
8 p.StartInfo.RedirectStandardOutput = true;
9 p.StartInfo.CreateNoWindow = false;
10 p.Start();
2 string fileName = setupPath + "Installer.msi";
3 Process p = new Process();
4 p.StartInfo.FileName = "msiexec.exe";
5 p.StartInfo.Arguments = string.Format(" /i {0} /passive", fileName);
6 p.StartInfo.UseShellExecute = false;
7 p.StartInfo.RedirectStandardInput = true;
8 p.StartInfo.RedirectStandardOutput = true;
9 p.StartInfo.CreateNoWindow = false;
10 p.Start();
//使用process类来执行dos命令
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
//开始卸载
process.Start();
process.StandardInput.WriteLine("cd C:\\mysql\\bin");
process.StandardInput.WriteLine("net stop mysql");
process.StandardInput.WriteLine("mysqld -remove");
process.StandardInput.WriteLine("exit");
process.Close();
//卸载完毕
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
//开始卸载
process.Start();
process.StandardInput.WriteLine("cd C:\\mysql\\bin");
process.StandardInput.WriteLine("net stop mysql");
process.StandardInput.WriteLine("mysqld -remove");
process.StandardInput.WriteLine("exit");
process.Close();
//卸载完毕
1//启动资源管理器,并打开指定路径
2 Process.Start("explorer.exe", "C:\\mysql");
2 Process.Start("explorer.exe", "C:\\mysql");
//启动浏览器,并打开指定的地址
string ipAddress = "127.0.0.1";
try
{
IPHostEntry ipHost = Dns.Resolve(Dns.GetHostName());
ipAddress = ipHost.AddressList[0].ToString().Trim();
}
catch (Exception)
{
}
Process p = new Process();
p.StartInfo.FileName = "iexplore.exe";
p.StartInfo.Arguments = "http://" + ipAddress + "/WebFinanceAllowance/";
p.Start();
p.Close();
//关闭打开的进程
if (!p.HasExited)
{
p.CloseMainWindow();
}
string ipAddress = "127.0.0.1";
try
{
IPHostEntry ipHost = Dns.Resolve(Dns.GetHostName());
ipAddress = ipHost.AddressList[0].ToString().Trim();
}
catch (Exception)
{
}
Process p = new Process();
p.StartInfo.FileName = "iexplore.exe";
p.StartInfo.Arguments = "http://" + ipAddress + "/WebFinanceAllowance/";
p.Start();
p.Close();
//关闭打开的进程
if (!p.HasExited)
{
p.CloseMainWindow();
}