Categories
Mastering Development

goto statements not working for some reason (Closing console every time) in .bat coding

I am coding in batch. I cannot get my if %var%== ____ goto ____ to work. I am new to batch coding so sorry if this is a stupid question but I know no other way to do this so if anyone could help that’d be great. here’s the code:

@echo off

first_page:

cls
echo                                       Would you like to ping or trace?
echo.

set /p var=                :
if %var%== ping goto second_page
if %var%== trace goto third_page

second_page:

cls
echo                                      What IP/Webpage do you want to ping?                                       
echo.
set /p var=                :
cls
echo                                                  Loading...
pause
cls
ping %var%
echo                                        Would you like to ping again?

set /p vartwo=                :
if %vartwo%== y goto first_page
if %vartwo%== n goto end_page

third_page:

cls
echo                                      What IP/Webpage do you want to trace?                                       
echo.
set /p var=
cls
echo                                                  Loading...
pause /t 10
tracert %var%
echo                                        Would you like to trace again?

set /p varthree=                :
if %varthree%== Y goto first_page
if %varthree%== N goto end_page

end_page

echo.
echo.

Leave a Reply

Your email address will not be published. Required fields are marked *