Sujet : Re: Do you use ADB (or ScreenCopy) with Android & Windows?
De : usenet (at) *nospam* andyburns.uk (Andy Burns)
Groupes : comp.mobile.androidDate : 09. May 2025, 11:49:58
Autres entêtes
Message-ID : <m864ulFhibcU4@mid.individual.net>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
Marion wrote:
y'mean some4thing like this?
I tried co-pilot
"write a script to reserve an tcp port"
it did it in Python
"in cmd.exe"
it wrote a one-liner using netsh
"make it retry until it finds an available port"
it added a loop
"limit to ten retries"
it obeyed
"set resulting port in a variable"
the result, which I haven't tried ...
@echo off
set /a port=8080
set /a retries=0
set /a max_retries=10
set reserved_port=
:retry
if %retries% GEQ %max_retries% (
echo Failed to find an available port after %max_retries% retries.
pause
exit /b 1
)
netsh int ipv4 add excludedportrange tcp %port% 1 >nul 2>&1
if %errorlevel% == 0 (
set reserved_port=%port%
echo Successfully reserved TCP port %reserved_port%
) else (
echo Port %port% is in use. Trying next...
set /a port+=1
set /a retries+=1
goto retry
)
echo The reserved port is: %reserved_port%
pause