0

so I am working on a ping batch file..

It gives you an option, and that option is to loop ping or to not loop ping.

Either choice, makes the ping not loop, now, I have figured out, which even ping command comes first, will be the choice either way.. for example, if the loop command is first, it will loop on either choice, same way for the other way around.

Here is my batch script..

@echo off
title Viper Ping by Sp00kie
echo " __     __  _                           ____    _                 "
echo " \ \   / / (_)  _ __     ___   _ __    |  _ \  (_)  _ __     __ _ "
echo "  \ \ / /  | | | '_ \   / _ \ | '__|   | |_) | | | | '_ \   / _` |"
echo "   \ V /   | | | |_) | |  __/ | |      |  __/  | | | | | | | (_| |"
echo "    \_/    |_| | .__/   \___| |_|      |_|     |_| |_| |_|  \__, |"
echo "               |_|                                          |___/ "
color a

choice /m "Loop ping?"
IF /I '%Input%'=='Y' GOTO LoopPing
IF /I '%Input%'=='N' GOTO NormalPing
echo "
echo "
echo "
echo "


:NormalPing
set /p UserInputPath1= "IP/Domain >> "
ping %UserInputPath1% -n 1 -w 2000 || goto pingFail
echo "
echo Ping was Successful to %UserInputPath1% at %date% %time%
Echo "
Echo "
Choice /m "Ping Another IP/Domain?"
if %ERRORLEVEL%==2 GOTO :EOF
cls
goto start
:pingFail

:LoopPing
set /p UserInputPath2= "IP/Domain >> "
ping %UserInputPath2% -t || goto pingFail
echo "
echo Ping was Successful to %UserInputPath1% at %date% %time%
Echo "
Echo "
Choice /m "Ping Another IP/Domain?"
if %ERRORLEVEL%==2 GOTO :EOF


pause
Sp00ked
  • 3
  • 1
  • I'm guessing that `choice /m "Loop ping?"` used to read `set /p input=Loop ping [Y|N]?` or similar. You need to now change the `If` responses to `ErrorLevel`s like you have with your other `choice` commands. – Compo May 02 '18 at 23:03
  • 1
    You should consider reading the help for the `choice` command. Tells you exactly how to access the response from the `choice` command. – Squashman May 03 '18 at 00:19
  • If you use `-t`, in which scenarios do you expect the script to continue with that section? and in which scenarios do your expect the `||` condition to be met? – Compo May 03 '18 at 01:19

0 Answers0