Wednesday, 29 April 2015

Create first batch(.bat) file using notepad

How can we create a simple batch(.bat) file using notepad.

Introduction

Batch files are basically a plain text files and can be created using simple notepad application. Don't use word pad or microsoft word as they don't produce pure text and uses their own formatting. Let's create a batch (bat) file using notepad.

Creating a batch (.bat) file

To create a batch simply follow below steps and you are done.
  • Add a notepad file and name it as sample.txt
  • Replace .txt extension to .bat or .cmd
  • Your final file name should be sample.bat or sample.cmd
We can create a batch file in two ways, either using .bat extension or using .cmd extension. The only difference is its type. If we use .bat extension then file type will be Windows Batch File and if we use .cmdextension then it will be Windows Command Script.

Using the Code

Let's add some code for this.
In this example I am using few keywords like @echomsg and pause which has been used to print a message, show message popup and to pause the screen respectively.
@ECHO =================Dot Net Sample Batch File Example====================
@ECHO Showing a 'hello world' message box...
msg * Hi.. How are you today? 
pause
Above code shows a message box saying "Hi.. How are you today?" and will print few lines on command prompt
See how simple it was. We can create a batch file and use it in many jobs.

No comments:

Post a Comment