您的位置:首页 > 运维架构 > Shell

c#如何用代码开启cmd指定命令(如:运行一个手机adb shell命令)

2013-10-12 10:36 411 查看
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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐