Whenever you have only one command after an if statement, you can just post it afterwards. I know Jerry had a great answer, but I just felt like adding more detail.
If I needed to perform multiple tasks, the (
would be very helpful. here's an example:
if %x%==1 (
:: do some stuff
:: do more stuff
:: do even more stuff
)
But if I only need to do some stuff
, I would just put it in one line.
if %x%==1 :: do some stuff
Since in your script, you are jumping to another label, once you hit that if statement, your away from that part of the script.. Here's what I mean:
if %x%==1 goto label_01
echo this won't get displayed unless %x% isn't equal to "1"
:label_01
echo anything after the "if" line wont get displayed, since we are here.
And since batch scripts are read by cmd.exe from left to right, and top to bottom, we can stack up those if
statements.
if %x%==1 goto label_01
if %x%==2 goto label_02
if %x%==3 goto label_03
:: we now know that %x% is not equal to 1, 2, or three. so now we can take advantage of that and post some script.
:: do some stuff
Since your script seems to be based off of a menu system, I recommend changing it up a bit:
cls
color 02
ECHO Welcome to your hacking console!
echo.
echo Press 1 to go back to the main menu
echo Press 2 to Tracerout
echo Press 3 to Lookup IP address
choice /c 123 >nul
set input=%errorlevel%
if %input%==1 goto main
if %input%==2 goto tracert
if %input%==3 goto IPlookup
This method saves us the need to goto error
. It also saves time, because now instead of typing out a whole word, you just type a number. If you type an unsupported number, nothing will happen.
Of course, this method won't work if your on XP.
BTW, a hacking machine? I remember scripting a couple of these. Except mine had the options of a DOS attack, and a browser password extractor :)