我正在开发一个项目,通过C#应用程序触发adb命令,我几乎完成了所有操作 我希望它做的事情,但我有通过adb命令批量安装应用程序的问题。
我尝试了以下代码: -
private void Select_Multiple_Apps_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = @"C:\";
openFileDialog1.Title = "Select your APK..";
openFileDialog1.FileName = "Choose File..";
openFileDialog1.Multiselect = true;
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;
openFileDialog1.Filter = " .APK|*.apk";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
TXT_BLK_INSTL.Text = openFileDialog1.FileName;
}
}
private void Install_Click(object sender, EventArgs e)
{
/*Process Bulk_Install = Process.Start("CMD.exe", "/c FOR %%n in (*.apk) DO adb install "%%n");
Bulk_Install.WaitForExit();
MessageBox.Show(".APK is Installed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);*/
}
但它不允许我使用批处理脚本代码,有没有其他方法可以批量安装应用程序(用户给出的路径)?
谢谢!
答案 0 :(得分:0)
命令必须为Process.Start("CMD.exe", "/c FOR %n in (*.apk) DO adb install \"%n\"");
Microsoft希望在脚本中使用%%<variable>
,在命令行中使用%<variable>