Please enable Javascript for better experience...
How to Create a batch file
By Big | Nov 17, 2014 | In Tutorials | Update: Nov 18, 2014 | Total Views [ 1489 ]
Taged In
(1 Like)
Rate

In this tutorial section I will explain 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 .cmd extension 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 @echo, msg 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 * hello world...
pause

Above code shows a message box saying "Hello World" 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.

<< Batch File Tutorial
Create SQL database using batch file >>

Share this

About the Author

Big
Rahul Jha (Big)
Founder, Developer dotnet-concept.com
Has working experience in different phases of Software Development Life Cycle (SDLC) in CMS, Gaming, Health Care and Financial Services domain using Agile pattern. Working experience in Design patterns, ASP.NET, MVC, Windows application, WCF, ADO.NET, SQL Server and Test Driven Development (TDD) environment with JQuery, JavaScript, N-Unit, Entity Frameworks, LINQ, Code Refactoring and Business Objects Models.

 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment