准备条件:
将adb.exe加入环境变量即可。
源代码
private string cmdExcute(string strInput)
{
strInput = strInput.Trim() + "&exit";
Process p = new Process(); //设置要启动的应用程序
p.StartInfo.FileName = "cmd.exe";//是否使用操作系统shell启动
p.StartInfo.UseShellExecute = false; // 接受来自调用程序的输入信息
p.StartInfo.RedirectStandardInput = true; //输出信息
p.StartInfo.RedirectStandardOutput = true; // 输出错误
p.StartInfo.RedirectStandardError = true; //不显示程序窗口
p.StartInfo.CreateNoWindow = true;//启动程序
p.Start();