【转】C# 后台开启 cmd执行命令
2015-03-05 10:23
260 查看
private void RunCmd(string cmd)
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
// 关闭Shell的使用
p.StartInfo.UseShellExecute = false;
// 重定向标准输入
p.StartInfo.RedirectStandardInput = true;
// 重定向标准输出
p.StartInfo.RedirectStandardOutput = true;
//重定向错误输出
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(cmd);
p.StandardInput.WriteLine("exit");
}
//删除浏览器的缓存和cookie
RunCmd("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8");
RunCmd("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2");
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
// 关闭Shell的使用
p.StartInfo.UseShellExecute = false;
// 重定向标准输入
p.StartInfo.RedirectStandardInput = true;
// 重定向标准输出
p.StartInfo.RedirectStandardOutput = true;
//重定向错误输出
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(cmd);
p.StandardInput.WriteLine("exit");
}
//删除浏览器的缓存和cookie
RunCmd("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8");
RunCmd("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2");
相关文章推荐
- 用C#调用CMD.exe,执行DOS命令
- c# 调用CMD命令执行dos命令
- C#程序调用cmd.exe执行命令
- C#调用cmd执行命令获取返回值
- C# 调用CMD,执行DOS命令
- C#程序调用cmd执行命令
- C#程序调用cmd执行命令(转)
- C#程序调用cmd.exe执行命令
- C#打开cmd,并在命令窗口执行相应的命令
- c#中调用cmd命令执行批处理文件
- C# 执行Cmd窗口中的命令 [复制文件实例]
- c#调用cmd执行相关命令
- C#程序调用cmd执行命令-MySql备份还原
- c#关闭系统进程以及如何调用cmd并执行命令
- C# WINForm 如何关闭系统进程,调用cmd并执行命令(隐藏CMD窗口) - 赤色火焰 - 京华志
- C#代码打开CMD.EXE 执行 DIR命令,并接收返回值
- C#调用cmd执行ftp命令
- C# 003 C#调用cmd.exe执行命令
- C#程序调用cmd执行命令
- C# 执行CMD 命令