What are Batch Files?

  • Buffer
  • Pin It
  • Sharebar
  • Buffer
  • Pin It

I recently was in charge of creating a silent install for an application. While many installations include a silent option, this one was a bit different. I had to also run other installs, as well as import registry settings, and also copy files.

To help me with this task I used a batch file that was easily able to handle everything I needed. If you haven’t used batch files before, then this post will explain what they are and how they can be used.

Batch File Overview

Batch files are nothing more than a text file that executes one or more commands from a command prompt. Unlike other executables that use the “.exe” extension, batch files use the “.bat” extension.

The one reason batch files are used is to execute many commands at one time, like in a batch. This means you don’t have to sit in front of your computer to execute each command separately.

In the early days of the PC, the most common batch file was autoexec.bat, which loaded when you started your computer. This file contained many driver and application settings that were needed to run your computer. This file was at times a source of frustration, especially to get the settings correct.

I still like to use batch files today, as they are quick and easy to create, and can be used to automate such things as a virus scan or defrag at specific times.

Creating a Batch File

As I mentioned, a batch file is easy to create. All you need is a text editor, such as Notepad. When you save a file in your text editor be sure to change the extension from “.txt” to “.bat”.

To execute a batch file, you can just double-click the file in Windows or type its name from a command prompt to execute the batch file.

For example, lets say you wanted to execute a file called “ProgramA.exe” from the “C:ApplicationA” directory. You would open up your text editor and type:

“C:ApplicationAProgramA.exe”

Once you save your batch file (remember to change the extension to “.bat”), you can then just double-click your batch file and “ProgramA.exe” would run.

If you wanted to also execute “ProgramB.exe” from “C:ApplicationB”, you would change your batch file like so:

“C:ApplicationAProgramA.exe”

“C:ApplicationBProgramB.exe”

This would execute both “ProgramA.exe” and “ProgramB.exe”.

If you wanted to print out a message to the screen while it ran, you can use the echo command like this:

echo Running ProgramA

“C:ApplicationAProgramA.exe”

echo Running ProgramB

“C:ApplicationBProgramB.exe”

While the above commands are simple, it shows how easy it is to execute more than once command at a time.

I currently use batch files to automate my virus scanner, anti-spyware, and defrag applications, as each of these applications can be executed from the command line. You can read how I do it in the post titled Automating Computer Maintenance.

 What are Batch Files?

About Paul Salmon

Paul Salmon is the founder of Technically Easy. He is a an experienced PC user, and enjoys solving computer-related problems that he encounters on a regular basis.

Facebook | Twitter | Google+

You may also like:

No thumbnail image

Restart or Shutdown Windows from a Batch File

DOS Prompt

Delete Files Older Than a Number of Days From DOS

No thumbnail image

How to Automate Your Computer Maintenance

No thumbnail image

Replacing an Application with Another in Windows

Do you have something to say? Let everyone know!

Commenting policy: All comments are moderated for spam. You must use your real name and not your website name or keywords. If a comment is deemed to be spam, then it will be deleted or edited. Links to your website within the comment body is not permitted, but you are free to use CommentLuv to add a link to your latest post. If you wish to add a link to your website, you can always contact me about submitting a guest post.






CommentLuv badge
This blog uses premium CommentLuv which allows you to put your keywords with your name if you have had 5 approved comments. Use your real name and then @ your keywords (maximum of 3)

Previous Post:

Next Post: