A few words of thanks would be greatly appreciated.

Create command files in batch

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 www.nameofwebsite.com initiate pings on IP addresses or domain name.
  • Tracert www.nameofwebsite.com: 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!


A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Create command files in batch », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!