gpt4 book ai didi

android - 使用 WINDOWS 在多个连接的设备上安装 apk

转载 作者:搜寻专家 更新时间:2023-11-01 07:51:57 25 4
gpt4 key购买 nike

我正在寻找一种解决方案,将所有 apk 安装到所有使用 Windows 的连接设备上的文件夹中。我到处都找过了,只能找到 Bash 解决方案。

这是我遇到的最好的 bash:

通过本网站 http://engineering.meetme.com/2014/07/quick-tip-how-to-install-or-uninstall-apks-on-multiple-android-devices-with-just-one-command/

#!/bin/bash
# Script adb+
# Usage
# You can run any command adb provides on all your currently connected devices
# ./adb+ <command> is the equivalent of ./adb -s <serial number> <command>
# Examples
# ./adb+ version
# ./adb+ install apidemo.apk
# ./adb+ uninstall com.example.android.apis
adb devices | while read line
do
  if [ ! "$line" = "" ] && [ `echo $line | awk '{print $2}'` = "device" ]
  then
      device=`echo $line | awk '{print $1}'`
      echo "adb -s $device $@ ..."
      adb -s $device $@
  fi
done

Now I wonder how to convert this into bat file ? Does anyone know how to do such thing please......

我可以手动执行此操作:我运行 adb devices,然后复制所有 ID 并替换为下面的代码

ECHO Running Bat script
@ECHO OFF
:: comment
adb -s <DEVICE_ID> install MyApk.apk
adb -s <DEVICE_ID> install MyApk2.apk
adb -s <DEVICE_ID> install MyApk3.apk

但我需要使这个过程自动化。

我需要学习如何获取所有连接的 devices_id 作为上面的 bash 代码。然后获取文件夹中的所有 .apk 文件(此 bat 文件所在的位置)。然后运行安装...

如果有人知道如何提供帮助,我将不胜感激。谢谢。

最佳答案

最后,设法正确实现它(将当前文件夹中的所有 apk 安装到所有连接的设备):

echo off       
setlocal EnableDelayedExpansion
for /f "tokens=*" %%f in ('C:\android\sdk\platform-tools\adb.exe devices') do (
for /r %%p in (*.apk) do (
set devicestr=%%f
set apk=%%p
if "!devicestr!"=="!devicestr:List=!" (
for /f "tokens=1" %%d in ("!devicestr!") do (
set deviceid=%%d
echo !deviceid!
echo !apk!
C:\android\sdk\platform-tools\adb.exe -s !deviceid! install !apk!
)
)
)
)

此行删除“已连接设备列表”:

if "!devicestr!"=="!devicestr:List=!" (

关于android - 使用 WINDOWS 在多个连接的设备上安装 apk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33934653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com