先将adb.exe环境加入系统环境变量
{
Process process = new Process();
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();
}
原文地址:https://www.cnblogs.com/fengyan8909/p/11450906.html