Create command files in batch

October 2016

What is a batch file?

A batch file has the .bat or .cmd extension.

It is actually a set of MS-DOS command "coded" in the form of text file (for which the extension was changed).

One opened, the commands written in this file will be executed.


  • Uncheck the "Hide file extensions of the type known in the advanced options of Windows Explorer.
  • Use a text editor that saves the file in plain text (not binary).

Create a blank batch file

  • This is the basis for creating all type of batch files:
  • Right click on the desktop -> New -> Text Document;
  • Open this file and rename it as .bat or .cmd

Some useful examples of MS-DOS commands

  • chkdsk: to check for errors on the filesystem.Note that: it can be used with the /f option to correct errors (requires restart the machine after confirmation O).
  • Ping initiate pings on IP addresses or domain name.
  • Tracert Determines the route from your PC to remote IP addresses or domain name..
  • Vol C: give the name of a disk drive and the serial number of the latter (Replace C: with the drive of your choice).
  • Title TheTitleOfyourchoice: Change the title of the MS-DOS windows.
  • Echo TheTextOfyourchoice: Displays text on screen
  • Shutdown parameters:
    • r: Restart the system.
    • s: Turns off the system.
    • p: Turns off the computer power without the usual delay. (For Vista and Seven).
    • h: Set local computer into hibernation.
  • rundll32.exe user32.dll,LockWorkStation: Locks the local computer.
  • tasklist: Displays all running processes and their PID.
  • Time: change the system time.
  • systeminfo: Gives information on the physical and software configuration of the machine.
  • Print pathtotextfile: Print a text file or a photo. Enter the address of the file as such: print *C:windowsphoto.jpg
  • exit: Exit the actual MS-DOS window (always placed this command at the end of your batch files).
  • cls: cleans out the actual screen.

These are the main MS-DOS command, of course there are still hundreds.

Create a batch file

Simply open your blank batch file and enter the commands you want:

Note that

It is clear that these commands are simple and implies low-risk,but still it is important to pay close attention to some MS-DOS commands that, if badly used may be dangerous!

Related :

This document entitled « Create command files in batch » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.