using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
public static class M_ProcessExcuter {
[MenuItem("cmd/excueDoc")]
public static void ProcessExcuteDoc()
{
string path="Ping baidu.com";
StartCmd(path);
}
private static void StartCmd(string Command)
{
//Command = Command.Trim().TrimEnd('&') + "&exit";//说明:不管命令是否成功均执行exit命令,否则当调用ReadToEnd()方法时,会处于假死状态
// string output = null;
Process p = new Process();//创建进程对象
p.StartInfo.FileName = @"C:\Windows\System32\cmd.exe";//设定需要执行的命令
//p.StartInfo.CreateNoWindow = false;//不创建窗口
// string comStr = comd1 + "&" + comd2 + "&" + comd3;
p.StartInfo.UseShellExecute = true; //是否执行shell
p.StartInfo.RedirectStandardInput = false;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.Arguments = "/k "+ Command;// 单个命令
p.Start();
//p.StandardInput.WriteLine(Command);
// output = p.StandardOutput.ReadToEnd();
p.StandardInput.AutoFlush = true;
p.StandardInput.Close();
p.WaitForExit();//等待程序执行完退出进程
p.Close();
}
private static void CmdExcute()
{
Process.Start(@"C:\Windows\system32\cmd.exe","c:");
Process.Start(@"C:\Windows\system32\cmd.exe", "ping baidu.com");
}
private static void SimpleExcute()
{
Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "https://www.cnblogs.com/yangxiaohang");
}
}