how to create a batch file - basics


A simple batch file is a text file containing a set of command prompt commands. A simple editor is sufficient to create the batch file. A text file saved in Windows/DOS with the extension .cmd or .bat, can be executed directly. Especially for very simple processes, for example copying files or folders, batch files may still be easier than using PowerShell. At the latest, if commands should not be executed in sequence and certain if-queries, loops or functions are necessary, I would recommend the use of PowerShell.

Create a Batch-File

A new batch file can be created in any editor. .cmd or .bat should be used as the file extension. In the Windows editor, the file name should be placed under quotation marks so that “batchfile.cmd.txt” is not saved as the extension, but “batchfile.cmd”:



Batch commands are then written to the file in a separate line each time. When executing the file (double click) the lines are processed one after the other.
A right click “edit” opens the editor again to edit the file.

See also: Structure of a Batch File Syntax

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2022-09-23 from Bernhard 🔔


Top articles in this section


sleep or wait in batch files: pause cmd
The function wait or sleep was not available in BATch files by default.Remedy is a small detour via the ping Command

Structure of a batch file Syntax: echo off cmd
If you have created a batch file, you can write a command in each line, see: how to create a batch file - basics. The commands are executed in sequence when the file is started. The behavior of the output can be adjusted as follows:

Practical examples with batch
Handling variables in Windows Batch (command prompt) Read all variables Variables can be read out in the command prompt with the set command:

Questions / Comments