batch-file - stygcheck 一遍又一遍地循环
问题描述
我制作了一个脚本来启动一个哇服务器然后哇本身。但由于某种原因,函数 stygcheck 不断循环。老实说,可能有一个我没有看到的错字,但我希望其他人检查一下以确保
echo off
cls
rem Stuff that makes sure stygiancore and wow are are found and accessible
:stygcheck
echo Checking for StygianCore
set stygroot="H:\StygianCore"
if exist %stygroot%\Server\Core\authserver.exe goto wowcheck: else goto styg-not-found:
:wowcheck
echo Checking for WoW
set wowroot="H:\World of Warcraft"
if exist %wowroot%\WoW.exe goto 1: else goto wow-not-found:
:styg-not-found
echo StygianCore not found. Please make sure the location is valid and you haven't modifed the file names at all
echo You may change the varible here temporarily but make sure you set the varible stygroot in the script to the root folder of stygiancore
echo It should be near the top
set /p stygroot="Please enter the path to root of stygiancore: "
goto stygcheck:
:wow-not-found
echo World of Warcraft not found. Please make sure the location is valid and you haven't changed the file names at all.
echo The varible may be changed here temporarily but i would advise changing the varible in the script. It should be near the top below the function
echo stygcheck
set /p wowroot="Please enter the path to the folder where WoW is installed: "
goto wowcheck:
:banner
echo /============================================\
echo I \ /\ / _ \ /\ / I
echo I \ / \ / / \ \ / \ / I
echo I \/ \/ \_/ \/ \/ I
echo I Stygian Core and WoW starter I
echo I See /? for options and help I
echo I (Still working on this one) I
echo \============================================/
echo.
echo This script starts the WoW server before executing WoW itself
echo The server may take a minute or 2 to start, please be paitent
goto mysql-chk:
rem Message when something else fails such as mysqld or something
:fail
echo It appears the %STYGERROR% has failed to execute
echo Please try launching the program that failed
echo manaully to see whats wrong. Sometimes this
echo is caused by the MySQL server taking longer
echo then usual to start up. If thats the case,
echo try again.
pause
exit /B
rem First of the server program checks. This sees if mysqld is already running by looking for a pid file
:mysql-chk
echo Checking to see if MySQL is running
if exist "%stygroot%\Server\MySQL\data\*.pid" goto auth:
goto mysql:
rem Starting mysqld if neccesary. Does this by launching mysqld first and then checking the pid's contents and then checking tasklist for it. Also if mysqld has a
rem problem, this sets the error variable to mysql and runs fail
:mysql
echo Starting the MySQL server
cd "%stygroot%\Server\MySQL\bin"
start mysqld --defaults-file=..\my.ini --console
sleep 15
set /p "pid1="<"%stygroot%\Server\MySQL\data\*.pid"
tasklist /fi "pid eq %pid1%"
if %ERRORLEVEL%==0 goto auth-chk:
set "STYGERROR=MySQL Server"
if %ERRORLEVEL%==1 goto fail:
rem Auth server check. Should be obvious by now
:auth-chk
echo Checking if the Authentication server
if exist "%stygroot%\Server\Core\authserver.pid" goto world-chk:
goto auth:
rem Starts authserver if neccesary. Same stuff as the mysqld part but modified to suit authserver
:auth
echo Starting the Authentication server
cd "%stygroot%\Server\Core"
start authserver.exe
sleep 5
set /p "pid2="<"%stygroot%\Server\Core\authserver.pid"
tasklist /fi "pid eq %pid2%"
if %ERRORLEVEL%==0 goto world-chk:
set "STYGERROR=Authentication Server"
if %ERRORLEVEL%==1 goto fail:
rem World server check. Should even state what this does?
:world-chk
if exist "%stygroot%\Server\Core\world.pid" goto start-2:
goto world:
rem World starter. Surprise! It starts worldserver! Who would've thought?
:world
echo Starting the World server
cd "%stygroot%\Server\Core"
start worldserver.exe
sleep 5
set /p "pid3="<"%stygroot%\Server\Core\world.pid"
tasklist /fi "pid eq %pid3%"
if %ERRORLEVEL%==0 goto start-1:
set "STYGERROR=World Server"
if %ERRORLEVEL%==1 goto fail:
:start-1
echo Server program(s) launched
echo Now launching WoW itself
cd %wowroot%
Wow.exe
exit /B
:start-2
echo All programs for the server have been executed already
echo Starting WoW
cd %wowroot%
Wow.exe
exit /B
goto stygcheck:
解决方案
推荐阅读
- git - Git - 多次应用相同的更改
- javascript - 如何从字符串数组中删除双引号
- docker-swarm - Traefik 仪表板上的 401 > 健康是因为 Basic Auth HTTP?
- python-3.x - Statsmodels 季节性分解 - 趋势不是直线
- reactjs - react axios setState渲染循环错误
- php - 如何使用 php 服务器在 amazon linux 上安装 maxmind geoLite2?
- wordpress - WP Woocommerce 显示弹出窗口添加到购物车按钮
- git - 如何删除一些过去重复的 git 提交?
- mysql - 从 mysql 5.7 中的 json 数组中提取键
- python - 如果使用条件,应用回调不会更新图表