@echo off chcp 65001 > nul setlocal set PORT=8089 echo 正在检查端口 %PORT% 是否可用... :loop netstat -ano | findstr ":%PORT%" >nul if "%errorlevel%"=="0" ( echo 端口 %PORT% 已启动,开始启动Nginx服务... goto check_nginx ) else ( echo 端口 %PORT% 尚未启动,请等待重试... timeout /t 5 >nul goto loop ) :check_nginx echo 检查Nginx服务是否正在运行... tasklist /FI "IMAGENAME eq nginx.exe" | find /I /N "nginx.exe" >NUL if "%ERRORLEVEL%"=="0" ( echo Nginx服务已经在运行,重新加载Nginx配置... nginx.exe -s reload ) else ( echo Nginx服务正在启动,请稍等... start nginx.exe timeout /t 5 /nobreak > nul ) echo 检查Nginx服务是否已经启动成功... tasklist /FI "IMAGENAME eq nginx.exe" | find /I /N "nginx.exe" >NUL if "%ERRORLEVEL%"=="0" ( echo Nginx服务已经成功启动。 goto successful_actions ) else ( echo 服务启动失败,正在重新尝试... goto check_nginx ) endlocal :successful_actions echo 所有服务启动成功... echo 准备打开程序... :: start http://localhost:80 :: start http://192.168.3.20:8083 :: 调用同级目录下的脚本文件创建快捷方式到桌面 call copy__shortcut.bat :: 启动程序 call start_program.bat :: 暂停,等待用户按下任意键 :: pause exit