@echo off
setlocal
cd /d %~dp0
for /f "tokens=1" %%a in ('tasklist ^| findstr /i "EasyWebSvr.exe"') do taskkill /f /im "%%a"
copy /Y  player\back\80\EasyWebSvr.ini player\EasyWebSvr.ini

set "PORT=80"
set "IP=0.0.0.0:80"
for /f "tokens=2,5" %%a in ('netstat -ano') do (
    if %%a == %IP% (
        set "PID=%%b"
        goto found
    )
)

goto exit

:found
for /f "tokens=1" %%a in ('tasklist /nh /fi "PID eq %PID%"') do (
	set PROGRAMNAME=%%a
	copy /Y  player\back\80\EasyWebSvr.ini player\EasyWebSvr.ini
	set "PORT=40404"
)

:exit
start player/EasyWebSvr.exe
start "" http://localhost:%PORT%/

endlocal