Scrcpy: Automating scrcpy on Windows with a .cmd script

Created on 7 Jun 2018  路  7Comments  路  Source: Genymobile/scrcpy

create a file called [name].cmd, with the contents:

taskkill.exe /IM adb.exe /F
adb.exe devices
adb.exe tcpip 5555
adb.exe connect 192.168.1.65:5555
cd C:\Users\dev\Documents\android\mirror\scrcpy
scrcpy.exe -s 192.168.1.65 -b4M --max-size 900
pause

change the cd command to reflect the path of scrcpy. Ensure you use the same adb.exe provided with scrcpy otherwise you may get errors (if your Windows PATH has a newer version, as was the case for me).

Plug device in, run [name].cmd, then you can disconnect cable and use wirelessly. You can also run the .cmd again without using the cable.

Most helpful comment

of course it doesn't work if the device is not liste in the arp -a command. Also when you have multiple device with adb on the network that would be a problem. but..... well for the simple case it works and you don't need to do anything

All 7 comments

maybe that script can even be improved by automatically searching for a working ip in your network. You also don't need the device plugged in before!

the following script(save as xxx.bat file) works for me finding the correct ip (you need to change "dynamisch" to "dynamic" if you're using an english windows)

for /f "tokens=1,3" %%A in ('arp -a') do ^
if "%%B"=="dynamisch" adb.exe connect %%A:5555 && scrcpy.exe -s %%A -b4M --max-size 900

I assume that script is sitting in the scrcpy folder. Also using WIFI ADB app(https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb) on my phone. And using alt+print for screenshots of the window.

of course it doesn't work if the device is not liste in the arp -a command. Also when you have multiple device with adb on the network that would be a problem. but..... well for the simple case it works and you don't need to do anything

@eikaramba

Thanks it will same me lot of time with my friends and customers, I have a small computer shop and lot of time I have to support customers, friends and volunteering with elderly and their tablets/phone.

I have tried Webkey free service but is is a little bit slow and don't support copy/paste and don't support long click too. Also no need for Root.

So using my DWS services to remote in their computers and running the scripts preinstalled will be better and faster for me than trying to remote directly in their phones/tablets.

I'm pretty sure it this script could be done on other platform like Mac too if needed.

One last thing do you know of a software that would prevent sleeping when using ADB with USB I could just use the Android dev options to do it but on ADB TCP it's another thing.

Anyway thanks again for this little script it will make my life so more easy. 馃槉

@rom1v You should put this script in the ReadMe for Windows since it's pratically "plug and play" to use Scrcpy" wirelessly with it. 馃榾

Note: By the way in french it "dynamique" you have to use 馃槈 Also you could add just one small line at the beginning of the script to kill ADB.exe if there is a version runing:
taskkill /f /im adb.exe

Regards :octocat:

@mikhoul after some time of usage i can say my script above is NOT bulletproof. especially if you just connected your phone and turned on wifi adb often times the phone is not yet visible in the arp -a command. currently i don't have a solution for that.

why was this script deleted? am looking for something like this....

I don't know why @thecodingdude deleted the content when they closed the bug.

I just restored the original content.

Here's the script I use with wifi connection:

REM scrcpy -b2M -m800

REM scrcpy -M -m1280

REM scrcpy -b2M -m1024

REM scrcpy -b2M -m1580

REM pause

taskkill /f /im adb.exe

REM adb.exe devices
adb.exe tcpip 5555
REM ***Replace IP Address with your***
adb.exe connect 192.168.0.101:5555  
REM ***Replace the path with your own path***

REM scrcpy.exe -s 192.168.0.101 -b4M -m900

scrcpy.exe -s 192.168.0.101 -b8M

REM PING localhost -n 3 >NUL

rem Pause
taskkill /f /im adb.exe

Maybe it will help somebody. :octocat:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

behzadpooldar picture behzadpooldar  路  4Comments

mttmllns picture mttmllns  路  3Comments

SuryaElavazhagan picture SuryaElavazhagan  路  4Comments

tonyyang924 picture tonyyang924  路  4Comments

targor picture targor  路  3Comments