Skip to content

Basics of (Windows) Batch scripting

Posted in VIDEOS

BATCH Basics For Complete Beginners – A little bit of everything tutorial 02 || HOXFRAMEWORK
Welcome to batch scripting.
OS used :Windows 8, any other version of windows should work.
Firstly we are going to start with making a new file and naming it with an extension .bat
if you cannot do this, run notepad with WINDOWS KEY + R (and type in “notepad”) and write stuff
inside it, save it as .bat
So lets start with the code. First command turns “ECHO” off, makes it invisible
when printing out our data. hey man line will just say hey man, ECHO is a command
for printing this out, we made it hidden so it will just print “Hey man.”
Pause command makes the program start until user input.
And now let’s add some color into it.
1.
Now let’s enter some directories here with:
2.
Now ofcourse you wont type my directory you will type your own.
Let’s jump to my premade programs.
1st.bat :
3.
1st.bat does a ECHO OFF like previously said, changes color, says hello world,
pauses, ECHO-es “ninja” to something.txt (one > means add it to the new file,
or delete everything from an existing one clean and then add it in, >> means
just edit the existing file , add whatever to the next line)
and turtle to something.txt as well.
FTYPE is a command that literally just looks cool, it dumps out some sort
of directories , like TREE or so? I’m not sure this just looks cool you dont actually
have to use it, it doesnt do anything special. At least not for the purpose of this tutorial.
Pause again, mkdir (make a new directory) called testdir
then enter it with cd
then save “teenage mutant” to something.txt file that doesnt exist but will be created
cause we used (>) and not (>>)
then cls – clear the screen
then pause again
-So i ran the program to show you how it works.
-Now lets move on to the next one
-dirs.bat doesnt do anything specific, except for show you how commands
work,for example ipconfig
4.
-Now let me show you the example of a loop, loop starts with :loop and ends
with goto loop, it literally returns to :loop and goes trough all the commands
that you wrote in between. It doesn’t have to be called :loop with goto loop
it can be called whatever you want
5.
-Then the 3rd.bat displays how to display wlan profiles,and kill a service
,you can also use :
taskkill /IM task.exe for exe files.
6.
-And here i am gonna show you why netsh wlan thing doesn’t work
but it could, if you specify the name, like i did.
1.
@ECHO OFF
color 0a
ECHO Hey man.
pause
2.
@ECHO OFF
color 0a
ECHO Hey man.
cd Vajdeos
dir
pause
3.
@ECHO OFF
color 0a
ECHO Hello world
pause
ECHO ninja > something.txt
ECHO turtle >> something.txt
ECHO items saved.
pause
FTYPE
pause
mkdir testdir
cd testdir
ECHO teenage mutant > something2.txt
cls
pause
cd Vajdeos
dir
pause
4.
@ECHO OFF
color 0a
dir > directory.txt
ipconfig >> directory.txt
5.
@ECHO OFF
color 0a
:loop
FTYPE
TREE
goto loop
6.
@ECHO OFF
color 0a
netsh wlan show profiles > wifiprofiles.txt
net stop wuauserv