C#调用cmd应用程序

通过在C#中编写程序,需要用到:Diagnostics,这里写的是调用cmd命令,新建一个名叫cmd1的文件:输入命令是p.StandardInput.WriteLine(@“md C:\Users\user\Desktop\cmd1”);

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace stadyIdent
{
    class Program
    {  
      static void Main(string[] args)
        {
            Process p = new Process();//实例进程类;
            p.StartInfo.FileName = "cmd.exe";//定义需要操作的exe文件名;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.UseShellExecute = false;
            p.Start();
            p.StandardInput.WriteLine(@"md C:\Users\user\Desktop\cmd1");
            p.StandardInput.Flush();

        }
    }
}

猜你喜欢

转载自blog.csdn.net/DOUBLE121PIG/article/details/88949652