0xploit.com

Python/Perl/Bash ★ ☆Devil Child's Batch File Coding Tutorial ★ ☆

jalshaKIller

New member
Devil
Joined
Apr 29, 2023
Messages
8
Location
Russia
Hellcoins
♆153
Well, I see that you have decided to take part on this journey of batch coding. I am just going to let you know beforehand that some of the stuff after this can get annoying if you have errors in your code, so don't give up! Anyways, let's get on with the tutorial.

First you are going to want to open up a normal text file in notepad. Then you are going to want to type something like this:
[Image: wRL78.jpg]


That "Echo" command is the best way to communicate to the person using your batch file. It will display a message on the screen with whatever you typed. Now you can go ahead and save by changing the .txt to a .bat, and making sure it is on "All Files" as the save option:
[Image: lC81r.jpg]


Now run your batch file, wherever you saved it. Did you see a flash on your screen? That was the batch file coming up and disappearing almost instantly. The reason for this is because there was no command to make it wait for the user to close it. What you are going to need to do is right click on the batch file and click on "Edit":
[Image: N5z1V.jpg]


Now you are going to want to type the word "pause" on the line afterwards, like so:
[Image: 59nHH.jpg]


The command pause waits for the user to press a certain button or use a certain function (in this case, any key on the keyboard). Now you can save it again. Run your batch file again, and it should look something like this:
[Image: AGMRy.jpg]


Oh gosh, another problem? Yes. This time the issue is that the batch program is displaying the directory of where the command is coming from. In my case, it is showing the path to the desktop, where I have the file saved. But there is a very easy fix to this. Open it up using the "Edit" option in the right click menu, and type "@echo off" a line BEFORE the "echo" command line:
[Image: iuz63.jpg]


This "@echo off" is the SINGLE MOST IMPORTANT COMMAND YOU WILL EVER USE IN A BATCH FILE EVER. Sorry about the all caps, I was just trying to get it through your head that it is the SINGLE MOST IMPORTANT COMMAND YOU WILL EVER USE IN A BATCH FILE EV.. fine, I'll stop now. There is a little more of an in-depth explanation I could give you here, but the easiest way to explain it is that it basically covers up that directory, so that you don't see the actual command being processed, and just the output. Alright, now that I am done explaining that to you, save your batch file and run it:
[Image: 9rhFc.jpg]


Success! You have made your first batch file. Doesn't matter at this point how complex it is, because at the end of this tutorial you'll be able to make a complex one yourself. On the next page, I will be talking about making your batch file wait a period of time, and also how to use user input to operate the commands you want.
 
Top