参考下面的:ProcessStartInfo MyStartInfo = new ProcessStartInfo();
MyStartInfo.FileName = "cmd.exe";
MyStartInfo.UseShellExecute = false;
MyStartInfo.RedirectStandardInput = true;
MyStartInfo.RedirectStandardOutput = true;
MyStartInfo.RedirectStandardError = true;
Process MyProcess = new Process();
MyProcess.StartInfo = MyStartInfo;
MyProcess.Start();
MyProcess.StandardInput.WriteLine("dir");
strOutput = MyProcess.StandardOutput.ReadToEnd();MyProcess.StandardInput.WriteLine("type");
strOutput = MyProcess.StandardOutput.ReadToEnd();MyProcess.StandardInput.WriteLine("pause");
strOutput = MyProcess.StandardOutput.ReadToEnd();MyProcess.WaitForExit();
MyStartInfo.FileName = "cmd.exe";
MyStartInfo.UseShellExecute = false;
MyStartInfo.RedirectStandardInput = true;
MyStartInfo.RedirectStandardOutput = true;
MyStartInfo.RedirectStandardError = true;
Process MyProcess = new Process();
MyProcess.StartInfo = MyStartInfo;
MyProcess.Start();
MyProcess.StandardInput.WriteLine("dir");
strOutput = MyProcess.StandardOutput.ReadToEnd();MyProcess.StandardInput.WriteLine("type");
strOutput = MyProcess.StandardOutput.ReadToEnd();MyProcess.StandardInput.WriteLine("pause");
strOutput = MyProcess.StandardOutput.ReadToEnd();MyProcess.WaitForExit();
解决方案 »
- 【初学者求教】有办法确定某一条数据的所在行数么?(自增ID已经不准了)
- 解释下ado.net连接的事务锁定行为
- 把一个页面的表单Post到另外的一个页面,请问如何在另外一个页面获取值
- 大家相信0和1能够让金属产生思想吗
- 请问如何将String转换为Hex String?
- 如何取得修饰HTML元素的CSS式样?
- myblog beta2测试,完全兼容msn皮肤,首页拖动排位...
- 老板要做在线电影网站,想请教技术问题.
- ★★ 强烈推荐!!! .Net Media多媒体类库升级版Media_EE推出★★
- 定制控件的属性问题
- trackBar的简单问题
- 用c#实现智能设备的托盘图标,可是图标没有放在最下面一行?
MyStartInfo.FileName = "cmd.exe";
MyStartInfo.UseShellExecute = false;
MyStartInfo.RedirectStandardInput = true;
MyStartInfo.RedirectStandardOutput = true;
MyStartInfo.RedirectStandardError = true;
Process MyProcess = new Process();
MyProcess.StartInfo = MyStartInfo;
MyProcess.Start();
MyProcess.StandardInput.WriteLine("copy C:\myFile.txt c:\temp");
strOutput = MyProcess.StandardOutput.ReadToEnd();
MyProcess.WaitForExit();