//调用方法:RunCmd("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8");
static Action<string> RunCmd=(m)=>
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false; // 关闭Shell的使用
p.StartInfo.RedirectStandardInput = true; // 重定向标准输入
p.StartInfo.RedirectStandardOutput = true; // 重定向标准输出
p.StartInfo.RedirectStandardError = true; //重定向错误输出
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(m);
p.StandardInput.WriteLine("exit");
};
//发送电子邮件
MailMessage message = new MailMessage(sender, recipient, subject, message);
SmtpClient emailClient = new SmtpClient(erverName);
emailClient.Send(message);
//事先引用Visual Basic库
object siteResponds = My.Computer.Network.Ping(url);//ping目标地址
My.Computer.Network.DownloadFile(url, location);//下载
My.Computer.Network.UploadFile(localFile, address)//上传
object isAvailable = My.Computer.Network.IsAvailable;//确定网络是否可用