CMD Master
Back to Blog
Arnošt Havelka

Practical: Batch Intro

Write your first automation script.

Start Interactive Lesson
Practical: Batch Intro

A batch file is simply a text file containing a list of commands that are executed in sequence. They end with the .bat or .cmd extension.

The Mission

You will create a simple script called hello.bat that:

  1. Clears the screen.
  2. Prints a welcome message.
  3. Pauses so the window doesn't close immediately.

Step 1: Create the Script

We will use copy con to write the script directly.

Terminal
C:\Users\Student>copy con hello.bat

Step 2: Run the Script

Execute it by typing its name.

Terminal
C:\Users\Student>hello.bat

Key Commands Explained

  • @echo off: Prevents the commands themselves from being displayed, showing only their output.
  • cls: Clears the terminal screen.
  • pause: Stops execution and waits for user input. Without this, the script might run and close the window instantly.

Step 3: A More Useful Script (System Info)

Let's make a script that shows IP information.

Terminal
C:\Users\Student>copy con network.bat

Knowledge Check

1 / 3

What file extension is used for batch scripts?

References

These documentation links provide authoritative details for the commands used in this article.

Up Next

Variables and Time

Use environment variables and time commands to build predictable automation and timestamped logs.