0

So I'm Trying To Wipe Variables After Use, Easiest Way I Found Was To Declare As It Follow's

:PING_IP
set IP=
set /p IP="Enter IP To Ping(0 Cancel): "


if %IP%==0 (
        cls
        goto IP_MENU
)   else    (
        ping %IP%
        pause
        cls
        goto IP_MENU
)

But In This Case Bat Will End, Cause There No Action To Capture The NULL Value Var If Not Use, Unsure How To Proceed

  • Please read [How to stop Windows command interpreter from quitting batch file execution on an incorrect user input?](https://stackoverflow.com/a/49834019/3074564) There is explained everything you need to know how to prompt a user for a string like an IP address or `0` using `set /P` and how to process the user input in a safe and secure manner to handle really every user input correct. – Mofi Apr 15 '22 at 16:36

1 Answers1

0

Just Found Out I Can Use "||" To Assign A Value If User Does Not Responds, Hopes This help Anyone

:PING_IP
set /p IP="Enter IP To Ping(0 Cancel): " || set "IP=0"


if %IP%==0 (
        cls
        goto IP_MENU
)   else    (
        ping %IP%
        pause
        cls
        goto IP_MENU
)