Cool Batch Tricks - Part I

Hello guys,

        I'm starting a new series of posts in which I will show you some cool useful batch programs that you can use on your Windows PC. I will provide the code and will try to explain how it works. This is the first part of this series. Each part will contain two programs.


So, Let’s start.   

1.  What is a Batch Script??

      A Batch Script is a set of lines written in Batch Language. This language is used to execute commands in the Windows Command Prompt. This files have an extension of ‘.bat’. These can be executed without any need of compiler directly through Command Prompt. To know more about Command Prompt, go see my earlier post about Command Prompt.


Symbol of '.bat' files 

          Today, we will learn two cool but very easy and basi programs. They are :-


1.    The Matrix

     This program displays a cool Matrix of random numbers repeating continuously with a message displayed between them.

Code:

@echo off
color a
:Start
echo %random%%random%%random%%random%%random%You have been hacked!!%random%%random%%random%%random%%random%%random% 
/*  Its only one line from echo */ 
goto start



Output:



The first line ‘@echo off’ sets the echo to off. Echo means to display the current working path before each command. If its on then all paths are displayed,if it is off only outputs of commands that are performed are displayed.
In the next line ‘color a’, the color command is used to change the colour of the foreground and the background & ‘a’ sets the colour to green. To know more colours, open Command Prompt and type ‘color /?’(Without quotes).

          The next line ‘:Start’, states that a new section is being started named Start. We will use a command to come back here. This will form a loop.
         
          In the next line is ‘echo %random%.... %random%’, the echo command is used to display messages, %variable% is used to print the value of a variable. ‘Random’ generates random numbers.

          The last line ‘goto start’, sends the interpreter to Start section that we declared earlier to form a loop.


2.   SMS

This program used to send messages to other users that are on the same computer or to the clients of a server.


Code:

@echo off
color a
echo Type the message you want to send:
set /p a=MSG:
Echo Enter Username:
set /p b=User:
msg %b% %a%
pause
exit


Output:

 

I’ve already explained about the 1st, 2nd, 3rd & 5th lines. So, I won’t be explaining them again.

Moving on 4th & 6th line(they are almost similar), in this line we use the command ‘set’, which is used to assign values to a variable. ‘/p’ is an argument which prompts the user for input.
‘a’ is the variable name, and ‘MSG’ is the text to be displayed. Its Syntax is:

Set [arguements] <variable_name>=<Text>
          In the 7th line, we use ‘msg’ funcyion to send messages. We use the variables a,b in its arguments position. The Syntax of msg command is:

Msg [username] [message]
         
          It is the basic syntax, there are more advanced options available, to check them, open Command Prompt & type ‘msg /?’ (without quotes).

          The last second line contains only ‘pause’ word. This temperorily stops the execution and waits for the user to press any key.
         
          The exit command is used to exit from the program.


          So, these were the two programs of this tutorial. If you like this post please support us by sharing the post. You will get the .bat files of these programs down here:


  BAT Files :          1. The Matrix                                                                    2. Send MSG



          Don't Forget to visit our Facebook & Instagram pages, If you want to contact us, write us at Remedyhub11@gmail.com & don’t forget to Subscribe.

          .