小二哥's blog

----zhangzs8896(小二)

导航

.NET中如何执行命令行命令?

Posted on 2004-10-26 15:30  小二哥  阅读(790)  评论(0编辑  收藏  举报

net send 系统命令的使用!(首先应该打开Message服务)

方法一:

string str;
str
="Mr Zhang: " + MyText.Text;
System.Diagnostics.Process.Start(
"CMD.exe","/c net send 172.16.3.60 "+ str);

方法二:

string str;
str
="Mr Zhang: " + MyText.Text;
   System.Diagnostics.ProcessStartInfo
startInfo 
= new System.Diagnostics.ProcessStartInfo();
System.Diagnostics.Process p;
startInfo.FileName 
= "c:\\windows\\system32\\net.exe";
startInfo.Arguments 
= "send 172.16.3.60 " + str;
startInfo.WindowStyle 
=
System.Diagnostics.ProcessWindowStyle.Hidden;
= System.Diagnostics.Process.Start(startInfo);
p.WaitForExit();