-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToggleTether.cmd
86 lines (86 loc) · 3.47 KB
/
ToggleTether.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@echo off
Rem This script toggles tether on Android device via Android Debug Bridge, make sure USB debugging is on and platform-tools is installed on your computer before running.
Rem This script needs to be edited before use. (replace Your-Device-Name with your Android device name or IP)
title [ImAyx.top] Toggling Tether...
echo This script needs to be edited before use. (replace Your-Device-Name with your Android device name or IP)
Rem It's recommended that you remove the line above after you have done the edit.
Rem You can also remove the "-s" parameter if you're sure there'll be no more than one device connected to your computer at a time.
echo.
echo Enabling Wi-Fi on the device...
Rem These two operations are for compatibility of wireless debugging (so the setting can be toggled whether the phone is connected via USB cable or not), if you don't need to toggle tether wirelessly you can remove this part.
echo.
adb -s Your-Device-Name shell svc wifi enable
if %errorlevel% neq 0 (
title [ImAyx.top] Awaiting Response...
color 6
echo.
echo Failed to enable Wi-Fi on the device.
echo.
echo This operation is for compatibility of wireless debugging so the tethering setting can be toggled whether the phone is connected via USB cable or not, if you don't need to toggle tether wirelessly you can edit the script to remove this part.
echo.
echo Press any key to continue executing.
pause > nul
color 07
Rem Reset color
)
echo.
echo Connecting to the device via Wi-Fi...
Rem If your device runs Android 11+, I suggest that you run this command when it's connected via USB:
Rem adb tcpip 5555
Rem This will make the wireless debugging port always the default 5555, not an always changing annoying random port.
echo.
adb connect Your-Device-Name
if %errorlevel% neq 0 (
echo.
pause > nul
exit /b 1
)
Rem If your router doesn't support using the hostname, set up a static local IP address for your device either in your router panel or the device settings.
echo.
echo Opening up Tether Settings...
echo.
adb -s Your-Device-Name shell am start -n com.android.settings/.TetherSettings
if %errorlevel% neq 0 (
title [ImAyx.top] Toggle Failed!
color cf
echo.
echo Failed to open Tether Settings.
echo.
echo Please make sure USB debugging is on and platform-tools is installed on your computer before running.
echo.
echo It also might be because adb failed to connect to the device. Check the error message from adb above.
echo.
echo For platform tools, go to https://developer.android.com/studio/releases/platform-tools
echo.
echo ^(Hold Ctrl and click to open it directly in your browser^)
echo.
echo Press any key to exit.
pause > nul
color 07
Rem reset color
exit /b 2
)
echo.
echo Toggling Tether...
echo.
adb -s Your-Device-Name shell input keyevent 66
if %errorlevel% neq 0 (
title [ImAyx.top] Toggle Failed!
color cf
echo.
echo Failed to Toggle Tether.
echo.
echo Please make sure USB debugging is on and platform-tools is installed on your computer before running.
echo.
echo It also might be because adb failed to connect to the device. Check the error message from adb above.
echo.
echo For platform tools, go to https://developer.android.com/studio/releases/platform-tools
echo.
echo ^(Hold Ctrl and click on the link to open it directly in your browser^)
echo.
echo Press any key to exit.
pause > nul
color 07
Rem reset color
exit /b 3
)