Skip to content

Instantly share code, notes, and snippets.

@SeeFlowerX
Created July 19, 2023 02:19
Show Gist options
  • Save SeeFlowerX/1c2608006fadbeba2feab0df36bb07a3 to your computer and use it in GitHub Desktop.
Save SeeFlowerX/1c2608006fadbeba2feab0df36bb07a3 to your computer and use it in GitHub Desktop.
宿主机和虚拟机同时使用adb + 右键菜单

vm_adb.reg 下面的路径要根据自己放的位置改下

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenBat]
@="vm_adb"

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenBat\command]
@="cmd /c D: && cd D:\\ && vm_adb.vbs"

vm_adb.bat 这里面不等待个3s,会出现两个device,但实际上是一个

adb kill-server
start /min adb -a nodaemon server start
timeout /T 3 /NOBREAK
rem adb disconnect
adb forward tcp:5555 tcp:5555
rem pause

vm_adb.vbs

set ws=WScript.CreateObject("WScript.Shell")
ws.Run "vm_adb.bat",0

准备好上面的文件之后,双击vm_adb.reg添加注册表,然后鼠标右键就会有选项了

运行之后,在虚拟机中adb connect [宿主机host]即可

这样就不需要总是把手机连接到USB了,因为虚拟机中投屏不方便,画面还小

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment