Simple Batch Programming

183,099

20

41

Posted

Introduction: Simple Batch Programming

In this 'step by step' tutorial I will be showing you Simple Batch Programming. Once you have completed this step by step tutorial you may find batch programming as easy as pie (not the mathematical pie)

I will show you three different batch programs. One will be a load of random numbers, another will be how to make the program say stuff and last one how to type to the computer. (sorry if you know all this but i cant use the if command its complicated if you want to find out more type 'if /?')     

Step 1: Step One All the Different Colours You Can Use in Batch Programing.

You must have notepad to do this and you have to start with the following command:
@echo off

Since you can't read the pic you have to have a number then a letter for your different colours the number is the back ground and the letter is the writing. here are the numbers and letter:

Right first when your batch programing you have to write 'color' then one of the following numer and letter:

0= black      a= green
1= blue        b= apua
2= green     c= red
3= apua      d= purple
4= red          e= yellow
5= purple     f= bright white
6= yellow
7= white
8= gray 
9= light blue

Step 2: Batch Program 1 Matrix Program

I have enlarged the image so you may be able to see it. if you have seen 'The Matrix' you will see lots of different green numbers appear.

The ':start' is a label so the 'goto start' will go back to that label and replay whats after it in this case in a loop never ending (unless you close it)

The echo command will project what is after is on the same line but in the notepad style is says %random% that is the random number so in batch programming that is a random number.

As you can see the colour is a black back ground and green writing. 

In the second picture you can see how to save a batch program

1. once you have done the coding press save as...
2. name what you want to call it in this case Matrix Program (my one says different) but once you have named it you MUST put .bat at the last word of the title so it would be Matrix Program.bat
3. You MUST select save as type to all files like in the picture then you can press save.

Step 3: Batch Program 2 Deleting..

in this one its just like the matrix program apart from in stead of:
echo %random% etc.
this time it will be:
echo  Deleting... %userprofile%\documents\%random%
echo  Deleting... %userprofile%\documents\%random%\%random%

The %userprofile% is it will come up as c:\(name of your comuter)\
and this time the color is black background and red writing.

Its the same to save it just like the matrix program but you might save this as:
Deleting....bat

Step 4: The Last Batch Program Story Writing.

This one is more advanced than the others so try stay on track.

the same with the start as the matrix program but the 'SET /p userin1' is the command were you can type.
the userin is like a random or userprofile (This is a variable) when you want it echoed put echo %userin1% you still with me?
then the pause>null is a pause you can put pause but it will say 'press any key to continue...'  with this one it will go blank and once you press any key it will end.

Step 5: DONE!

now you are done with the 3 batch programs comment if you like or not and if you found it complicated or if you found it easy.

Also post if you have learned the commands and sent me some of your own batch programs.

THANKS for viewing Io kieran oI out :)

 

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Gluten Free Challenge

    Gluten Free Challenge
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

40 Comments

first of all thanks for the tutorial....i have a request could u plz share all the commands of cmd along with the description and the syntax then it would really be of great help to me.....thanks in advance

Is there anyway that I can make a interactive story with this file?

I know how to do that in python. use a if elif else algorithm

Oh yeah! There is! But not with "this" file in particular, Batch purpose you lots of things. But idk how do if can understand words with spaces. It'd be great if someone told us! Also, I made graphical games (with images), thanks external commands. So yep, you can make an interactive story as you could... Make a platform games, etc.

You can make an interactive story with batch (and I assume by 'interactive' you mean the choices the user makes affects the direction of the story) using simple input commands to use variables to take you to different labels. I'm not very experienced with batch myself but I've done it for a while now and it's very easy to use, all you really need to know how to do is to set the values of variables and be able to recall them later, which even I can do and relatively easy in my opinion.

A batch program run in start up but they work after 5 day at my time..like sunday ,saptember 5th at 7Pm ..

How to make this program

All of you .. Any idea to help me

I yet Dont Get You.... :/

The Matrix Program Whats That

Can you please make me learn each and every command of batch and it's description like what does it do please i really need to learn it!

Sorry for the late reply... well very late reply, and its been a while since I made this and have done any form of batch file coding so I may not be 100% correct on this but the matrix program just randomly generated a sequence of number and prints them on the screen in an infinite loop giving the effect of the random characters in the film the matrix. However in the film it is actually random ascii characters this is just numbers. The echo command is what will be printed after it. For instance if you put echo Hello World it will display Hello World in the console. The %random% is a built in variable that will generate a random number. I believe its 4 digits but I cant remember. The :start is called a label. This is like your function. This create a place which you can link back to using the goto command. so in this case this is an infinite loop as it will keep on going back to the start label and displaying the random numbers. Hope this helped and again sorry for the year late reply, been a but inactive.

u might wanna tell us what EXACTLY this batch will do when clicked on... it deletes stuff i guess.. but what? random things?