使用Process调用dos命令
来源:互联网 发布:尊荣财富网络借贷 编辑:程序博客网 时间:2024/06/09 17:23
The simplest way to run a command is:
System.Diagnostics.Process.Start ("cmd", @"/c copy c:/myfolder/*.* c:/mybackup");
You can get creative using System.Diagnostics.ProcessStartInfo... for instance you can have your command run without showing a window and capturing the output of the command to process it as you prefer (for instance, displaying it in your console). A simple example of this follows:
// create the ProcessStartInfo using "cmd" as the program to be run, and "/c dir" as the parameters.
// Incidentally, /c tells cmd that we want it to execute the command that follows, and then exit.
// To have more information, start cmd and type help cmd.
System.Diagnostics.ProcessStartInfo sinf =
// The following commands are needed to redirect the standard output. This means that it will be redirected to the Process.StandardOutput StreamReader.
sinf.RedirectStandardOutput = true;
sinf.UseShellExecute = false;
// Do not create that ugly black window, please...
sinf.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process p = new System.Diagnostics.Process ();
p.StartInfo = sinf;
p.Start (); // well, we should check the return value here...
// We can now capture the output into a string...
string res = p.StandardOutput.ReadToEnd ();
// And do whatever we want with that.
Console.WriteLine (res);
- 使用Process调用dos命令
- Process执行dos命令
- 使用Process进行DOS命令交互的简单应用
- 使用Process进行DOS命令交互的简单应用
- 使用T-SQL调用DOS命令
- C#中利用process类调用外部程序以及执行dos命令
- C#中利用process类调用外部程序以及执行dos命令
- C#中利用process类调用外部程序以及执行dos命令
- C#中利用process类调用外部程序以及执行dos命令
- C#中利用process类调用外部程序以及执行dos命令
- 调用Dos命令
- c#调用dos命令
- Java调用DOS命令
- JAVA调用DOS命令
- java调用dos命令
- c#调用dos命令
- java调用Dos命令
- Java调用dos命令
- 十大宽带共享组网方式推荐
- 一个利用JMF控制摄像头拍照的程序
- java note from web
- 全角半角转换函数 收集&汇总
- (转)查看sql server 数据库连接数方法
- 使用Process调用dos命令
- asp.net 上传图片并生成缩略图
- 什么是Web Service?
- GDI+ 中发生一般性错误的解决方法
- 在C#中简单的科学计算,包括幂数,指数,对数,Math类
- JDBC语句对象
- Edit控件密码窗口的秘密--一种全新的通用密码记录技术
- 《Windows程序设计》读书笔记------------->>Virtual-Key Codes (虚拟键码)<<翻译自MSDN
- NET命令的基本用法