Skip to content

Instantly share code, notes, and snippets.

@swablueme
Last active April 2, 2023 07:36
Show Gist options
  • Save swablueme/992e38a25fb89b61486084d5bd87ee13 to your computer and use it in GitHub Desktop.
Save swablueme/992e38a25fb89b61486084d5bd87ee13 to your computer and use it in GitHub Desktop.
Starts both sndcpy and srcpy together
@echo off
::number times restarting sndcpy
set /A "FIXEDCOUNT=0"
set Token=MAIN_%RANDOM%_%CD%
::start sndcpy
pushd sndcpy-with-adb-windows-v1.1\ & start "%Token%_1" cmd /c sndcpy.bat & popd
::start scrcpy
start "%Token%_2" cmd /c scrcpy-win64-v1.24\scrcpy.exe --stay-awake --turn-screen-off
:loop
tasklist /fi "WINDOWTITLE eq %Token%_1" | findstr "cmd" >nul 2>nul && set Child1=1 || set Child1=
tasklist /fi "WINDOWTITLE eq %Token%_2" | findstr "cmd" >nul 2>nul && set Child2=1 || set Child2=
::restart sndcpy and start srcpy only once if srcpy crashed
if not defined Child2 (
if %FIXEDCOUNT% equ 1 exit
taskkill /F /fi "WINDOWTITLE eq %Token%_1" | findstr "cmd"
pushd sndcpy-with-adb-windows-v1.1\ & start "%Token%_1" cmd /c sndcpy.bat & popd
start "%Token%_2" cmd /c scrcpy-win64-v1.24\scrcpy.exe --stay-awake --turn-screen-off
set /A "FIXEDCOUNT+=1"
)
timeout /t 1 > null
set /A "COUNT+=1"
goto loop
:endloop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment