Aug 25, 2018 11:29 PM
(This post was last modified: Aug 26, 2018 07:19 AM by Sir-Teabag.)
Hey all,
With help from Beigevenus we got this little script together to tell you whether a server is online or offline through an exact port, which I'm fairly certain you can't do in Batch alone (the port thing)
Hope it helps someone here!
With help from Beigevenus we got this little script together to tell you whether a server is online or offline through an exact port, which I'm fairly certain you can't do in Batch alone (the port thing)
Hope it helps someone here!
Code
set ip=IP to check
set port=1234
call :serverstatus
echo Server is %status%
::will return 'server is offline/online'
pause
::do other stuff here
exit
:serverstatus
if exist %temp%\server.txt del %temp%\server.txt
powershell TNC -ComputerName %ip% -Port %port% >%temp%\server.txt
set database=%temp%\server.txt
for /F "delims=" %%a in ('findstr /I /N "true" %database%') do set "datalookup=%%a"
if "%datalookup%"=="" (set status=offline) else (set status=online)
goto :EOF
