public int ExcuteEXE(string filename,string path,string args)
{
//声明一个程序信息类
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
//设置外部程序名
Info.FileName = filename;
//设置外部程序的启动参数(命令行参数)为test.txt
Info.Arguments = args;
//设置外部程序工作目录为 C:\
Info.WorkingDirectory = path;
Info.WindowStyle=System.Diagnostics.ProcessWindowStyle.Hidden;
//声明一个程序类
System.Diagnostics.Process Proc=new System.Diagnostics.Process(); try
{
//
//启动外部程序
//
Proc = System.Diagnostics.Process.Start(Info);

}
catch(System.ComponentModel.Win32Exception e)
{
Console.WriteLine("系统找不到指定的程序文件。\r{0}", e);
//return;
}
return 0;
然后在你要用的地方ExcuteEXE("net","","send "+TargetUser+" "+textMsg.Text);