C#程序调用CMD执行命令方法
2021-02-05 05:13
标签:nis window line 命令 serial err ESS 执行命令 use 先将adb.exe环境加入系统环境变量 { Process process = new Process(); } C#程序调用CMD执行命令方法 标签:nis window line 命令 serial err ESS 执行命令 use 原文地址:https://www.cnblogs.com/fengyan8909/p/11450906.html
process.StartInfo.FileName = "cmd.exe";
//process.StartInfo.Arguments = "adb deviecs";
process.StartInfo.WorkingDirectory = "C:/Users/Administrator";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.ErrorDialog = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.StandardInput.WriteLine("adb get-serialno > " + serialno_path);
Thread.Sleep(1000);
process.StandardInput.WriteLine("adb get-serialno");
process.StandardInput.WriteLine("exit");
process.StandardInput.AutoFlush = true;
process.WaitForExit();
process.Close();