c#如何用代码开启cmd指定命令(如:运行一个手机adb shell命令)
else if (this.Mode == TravelMode.AutoRecodeMode) { DateTime StartDate = DateTime.Now; string args = string.Format(" -jar \"{4}\" {0} {1} {2} {3}", this.SerialNumber, this.ScreenSize.Width, this.ScreenSize.Height, this.PackageName, jarLocation); //string args = @"-jar " +@"\E:\1010NewAppTest\bin\Debug\adb\TraversalApp.jar"+ " IJAEZ9INS8EUHMVK 720 1280 com.android.calculator2"; #if DEBUG System.Console.WriteLine(string.Format("[AndroidTraveler] ExecuteScript() -> AutoRecodeMode Args:{0}", args)); #endif //声明一个程序信息类 System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo(); //设置外部程序名 Info.FileName = "java.exe"; Info.RedirectStandardInput = true; Info.UseShellExecute = false; Info.Arguments = args; //声明一个程序类 System.Diagnostics.Process Proc; try { //启动外部程序 Proc = System.Diagnostics.Process.Start(Info); Proc.WaitForExit(); } catch (System.ComponentModel.Win32Exception exc) { Console.WriteLine("系统找不到指定的程序文件。\r{0}", exc); }
清清软件园 http://sillysoft.taobao.com