Create BATch file - CMD, BAT commands in Windows (DOS)

Diese Seite gibt es auch in Deutsch

BATch commands date back to the DOS era and are still a useful tool for certain uses, yet Windows PowerShell is usually the better choice for administering and automating tasks today, see: Windows PowerShell.

The commands described here were tested under Windows 2000/XP, but are also valid for Windows 10 / 11.


The command "help" in the Command Prompt provides an overview of the available commands. With the command name and /? more detailed information about the respective command can be displayed, e.g. xcopy /?

Applications of batch files

 @echo off 
 echo This is a Textfile
@echo off
 xcopy c:\Documents d:\save /D /E /Y /I
@echo off 
 set var=value
 echo %var% 
@echo off 
 echo in the loop
 goto start 
if exist %file.txt goto jump
@echo off 
 if exist %datei.txt goto jump
 echo File not found
 goto END
 echo File does not exist


 @echo off
 xcopy c:\so c:\so2
 if errorlevel 1 goto error
 goto end
 echo copy was not successful!

Create a 2nd file, add:

echo hello > temp.txt 
echo hello >> temp.txt 
set year=%date:~-4%
set month=%date:~-7,2%
set day=%date:~-10,2%
echo %year%%month%%day%

creates then e.g.:20050921

 CD html 
 PUT C:\documents\homepage\index.htm 
 CD .. 
 CD images
 put C:\documents\homepage\images\image.gif image.gif 
ftp -s:dieftpdatei.ftp
curl -T C:\documents\homepage\index.htm --user USERNAME:PASSWORD
positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2022-11-30 from Bernhard 🔔

Top articles in this section

Windows : create a missing recovery partition
When cloning a large hard disk to a smaller one, I lost the recovery partition. So far not bad, Windows works without recovery partition, but in case of an error the partition helps to get the PC up and running again. To summarize, here's how it works with the recovery partition: As long as the partition is still there, it can be deactivated and written to a file. If the partition gets lost unexpectedly, it can be recovered from the Windows setup media. This post is also available as a vide...

Windows 11 (10) without Microsoft Account : local - Offline Profile
Not everyone wants to use a Microsoft account when using Windows. Depending on the Windows edition, an offline account can be set up more or less easily. In the new Windows Pro editions, there is the option "Offline account", in the Windows Home editions, an offline account can only be set up if there is no Internet connection. In future Windows versions, the behavior could probably change.

Windows 11 22H2 (Build: 22621.1194) : show current version
Build means the kernel version of Windows. How current the Windows 10 or Windows 11 installation is, can be seen by the build number used.

Questions / Comments

By continuing to browse the site, you agree to our use of cookies. More Details