using System.Diagnostics; protected void Page_Load(object sender, EventArgs e) { Process.Start(@"D:\Program Files\CodeGear\Projects\发邮件\发邮件.exe", "123456"); }
使用Process对象:
System.Diagnostics.Process p=new System.Diagnostics.Process(); p.StartInfo.FileName="arj.exe" ;//需要启动的程序名 p.StartInfo.Arguments="-x sourceFile.Arj c:\temp";//启动参数 p.Start();//启动 if(p.HasExisted)//判断是否运行结束 p.kill();
项目中的例子:
Process p=new Process(); //p.Start(Server.MapPath("main.exe"),Server.MapPath(URL1)+" "+id+" "+Server.MapPath(DownURL)); p.StartInfo.FileName = Server.MapPath("main.exe"); //文件 p.StartInfo.Arguments = Server.MapPath(URL1) + " " + id + " " + Server.MapPath(DownURL); //命令 p.Start(); p.WaitForExit(3000); if (p.HasExited == false) { p.Kill(); } //3秒后强制退出