Create command files in batch

What is a batch file?

A batch file has the .bat or md 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.

Prerequisites

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 md

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).

: 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 ameofwebsiteom initiate pings on IP addresses or domain name.

initiate pings on IP addresses or domain name. Tracert ameofwebsiteom : Determines the route from your PC to remote IP addresses or domain name..

: 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).

: 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.

: Change the title of the MS-DOS windows. Echo TheTextOfyourchoice : Displays text on screen

: 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.

parameters: rundll32e user32.dll,LockWorkStation : Locks the local computer.

: Locks the local computer. tasklist : Displays all running processes and their PID.

: Displays all running processes and their PID. Time : change the system time.

: change the system time. s ysteminfo : Gives information on the physical and software configuration of the machine.

: 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

: Print a text file or a photo. Enter the address of the file as such: print * :windowsphoto.jpg exit : Exit the actual MS-DOS window (always placed this command at the end of your batch files).

: 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!

Leave A Comment