主要使用Process类
基本练习.调用QQ程序
//调用带参数的exe
public bool StartProcess(string filename, string[] args)
{
try
{
string s = "";
foreach (string arg in args)
{
s = s + arg + " ";
}
s = s.Trim();
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(filename, s);
myprocess.StartInfo = startInfo;
myprocess.StartInfo.UseShellExecute = false;
myprocess.Start();
return true;
}
catch (Exception ex)
{
Response.Write("启动应用程序时出错!原因:" + ex.Message);
}
return false;
}
调用可执行程序
protected void ButtonBack_Click(object sender, ImageClickEventArgs e)
{
string exe_path = @"d:\Program Files\Tencent\QQ\Bin";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "QQ.exe";
process.StartInfo.WorkingDirectory = exe_path;
process.StartInfo.CreateNoWindow = true;
process.Start();
if (process.HasExited)
{
Response.Write("<script>alert('complete!')</script>");
}
}
浙公网安备 33010602011771号