Friday, April 27, 2012

VOL - Dos Command :

It displays the disk volume label and serial number, if they exist.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'vol' command with its all possible parameters you can use following command. Its like help information to regarding that command.
vol/?
Syntax :
 VOL [drive:]
Use :

ver D:
Volume in drive D is Backup
Volume Serial Number is 2CE1-1AE3

The above 'vol' command with drive as parameter displays drive name and serial number of that drive.
If you not specify drive then it displays drive name and serial number where you are currently located in that directory.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > vol D:
 Volume in drive D is Backup
 Volume Serial Number is 2CE1-1AE3

D:\DINESH > _

VER - Dos Command :

It displays the Windows XP Version.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'ver' command with its all possible parameters you can use following command. Its like help information to regarding that command.
ver/?
Syntax :
 VER
Use :

ver
Microsoft Windows XP [Version 5.1.2600]

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > ver
Microsoft Windows XP [Version 5.1.2600]

D:\DINESH > _

TYPE - Dos Command :

It displays the contents of a text file or files.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'type' command with its all possible parameters you can use following command. Its like help information to regarding that command.
type /?
Syntax :
 TYPE [drive:][path]filename
Use :

type D:\techno.txt
This is text.. Welcome to www.technoexam.com !

- The above example displays contents from a techno.txt file which is located at D drive.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > type D:\techno.txt
This is text.. Welcome to www.technoexam.com !

D:\DINESH > _

TREE - Dos Command :

It displays or represents the folder structure of a drive or path graphically.
To view 'tree' with its all possible parameters you can use following command. Its like help information to regarding that command.
tree/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :
 TREE [drive:][path] [/F] [/A]

where,

/F : It displays the names of the files located in each folders.
/A : Use ASCII instead of extended characters.

Use 1:

tree C:
- It displays all folders/directory structures within all C:\ drive.

Use 2:

tree C: /F
It displays all folders/directories with files containing in it in C:\ drive.

Use 3:

tree C: /A

Output of Use 2:
tree command Fig.: Using, tree C: /F
Output of Use 3:
tree command Fig.: Using, tree C: /A

TITLE - Dos Command :

It sets the window title for the command prompt window.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'title' command with its all possible parameters you can use following command. Its like help information to regarding that command.
title /?
Syntax :
 TITLE [string]

where,
string : It specifies the title for the command prompt 
window.

Use :

title TechnoExam Editor

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > title TechnoExam Editor

D:\DINESH > _

Before Executing Title Command :
Before Executing Title Command Fig.: Before Executing Title Command
After Executing Title Command :
After Executing Title Command Fig.: After Executing Title Command

TIME - Dos Command :

It displays or sets the system time.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'time' command with its all possible parameters you can use following command. Its like help information to regarding that command.
time /?
Syntax :
 TIME [/T | time]
Use 1:

time
The current time is: 21:56:05.21
Enter the new time: 21:57:03

- 'time' command without parameters displays current time setting and it prompts for a new one time. You can change system time by entering new time or you can simply press ENTER to keep the same time with having no change in it.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > time
The current time is: 21:56:05.21
Enter the new time: 21:57:03

D:\DINESH > _
Use 2:

time /t
09:57 PM

- 'time' command with parameter /t, which tells the command to just output the current time only, without prompting for a new time.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > time/t
09:57 PM

D:\DINESH > _

REN / RENAME - Dos Command :

It renames a file or files.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'ren or rename' command with its all possible parameters you can use following command. Its like help information to regarding that command.
ren /?
or
rename /?
Syntax :
 REN [drive:][path]filename1 filename2 
 or 
 RENAME [drive:][path]filename1 filename2
Use 1:

ren c:\red.txt green.txt
- The above command renames red.txt file to green.txt which are located in C:\

[NOTE: You cannot specify a new drive or path for your destination file.]

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > ren  c:\red.txt green.txt

Use 2:

rename c:\green.txt red.txt
- The above command renames green.txt file to red.txt which are located in C:\

[NOTE: You cannot specify a new drive or path for your destination file.]

Output 2:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > rename c:\green.txt red.txt

Rem Command :It sets or records comments in a batch file or config.sys. It is most commonly used in Batch file programming. It enables to include remarks of you in a batch file. Syntax : REM [comment] Use 1: p1.bat(Using @echo off) @echo off rem Created by: www.technoexam.com rem Creation Date : 18-Nov-2011 09:21 AM echo This is actual text ! ver pause Output : This is actual text ! Microsoft Windows XP [Version 5.1.2600] Press any key to continue... Use 2: p2.bat (Without using @echo off) rem Created by: www.technoexam.com rem Creation Date : 18-Nov-2011 09:21 AM echo This is actual text ! ver pause Output : D:\ > rem Created by: www.technoexam.com D:\ > rem Creation Date : 18-Nov-2011 09:21 AM D:\ > echo This is actual text ! This is actual text ! D:\ > ver Microsoft Windows XP [Version 5.1.2600] D:\ > pause Press any key to continue...

It sets or records comments in a batch file or config.sys. It is most commonly used in Batch file programming.
It enables to include remarks of you in a batch file.
Syntax :

REM [comment]
Use 1:

p1.bat(Using @echo off)

@echo off
rem Created by: www.technoexam.com
rem Creation Date : 18-Nov-2011 09:21 AM
echo This is actual text !
ver
pause

Output :


This is actual text !

Microsoft Windows XP [Version 5.1.2600]
Press any key to continue...
Use 2:

p2.bat (Without using @echo off)

rem Created by: www.technoexam.com
rem Creation Date : 18-Nov-2011 09:21 AM
echo This is actual text !
ver
pause

Output :


D:\ > rem Created by: www.technoexam.com

D:\ > rem Creation Date : 18-Nov-2011 09:21 AM

D:\ > echo This is actual text !
This is actual text !

D:\ > ver

Microsoft Windows XP [Version 5.1.2600]

D:\ > pause
Press any key to continue...

RMDIR / RD - Dos Command :

It removes or delete a directory or folder.
To view 'rmdir or rd' command with its all possible parameters you can use following command. Its like help information to regarding that command.
rmdir/?

OR

rd/?
Syntax :

RMDIR [/S] [/Q] [drive:]path

or

RD [/S] [/Q] [drive:]path


where,

/S : It removes all directories/folders and files in the
 specified directory in addition to the directory itself
 also. It is special kind of command used to remove or
 delete a directory tree.


/Q : It is a Quiet mode, which do not ask if ok to
 remove a directory tree with /S.
Use 1:

rmdir /s c:\test1

Use 2:

rd /s c:\test2

Use 3:

rmdir /q c:\test3

Use 4:

rd /q c:\test3

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > rmdir /s c:\test1
c:\test1, Are you sure (Y/N)? y

D:\DINESH > rd /s c:\test2
c:\test2, Are you sure (Y/N)? y

D:\DINESH > rmdir /q c:\test3
The directory is not empty.

D:\DINESH > rd /q c:\test3
The directory is not empty.

D:\DINESH > _

Pause Command :

It suspends processing of a batch program and displays the message as 'Press any key to continue...'. It is most commonly used in Batch file programming.
Syntax :

pause
Use 1:

p1.bat

ver
pause
cls

Output :


D:\DINESH > ver

Microsoft Windows XP [Version 5.1.2600]

D:\DINESH > pause
Press any key to continue...

MOVE - Dos Command :

It moves files from one location to other location and renames files and directories.
To view 'move' with its all possible parameters you can use following command. Its like help information to regarding that command.
move/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :

To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination

To rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

where,

[drive:][path]filename1 : It specifies the location and name of the file or files which you want to move.

destination : It specifies the new location of the file. Destination can consist of a drive letter and colon, a directory name, or a combination. If you are moving only one file, you can also include a filename if you want to rename the file when you move it.

[drive:][path]dirname1 : It specifies the directory which you want to rename.

dirname2 : It specifies the new name of the directory.

/Y : It suppresses prompting to confirm you want to overwrite an existing destination file.

/-Y : It causes prompting to confirm you want to overwrite an existing destination file.

The switch /Y may be present in the COPYCMD environment variable. This may be overridden with /-Y on the command line. Default is to prompt on overwrites unless MOVE command is being executed from within a batch script.

Use :

move test.txt F:
- It moves test.txt file from current directory to F:\ Drive.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > move test.txt F:

D:\DINESH > _

MKDIR / MD - Dos Command :

It creates a new directory.
To view 'mkdir or md' command with its all possible parameters you can use following command. Its like help information to regarding that command.
mkdir/?

OR

md/?
* If command extensions are enabled MKDIR changes as follows:
* MKDIR creates any intermediate directories in the path, if needed.
Suppose that, directory 'a' does not exist then,

mkdir \a\b\c
is same as of :

mkdir a
chdir a
mkdir b
chdir b
mkdir c

If extensions are disabled then you have to type if extensions were disabled.

Syntax :

MKDIR [drive:][path]

or

MD [drive:][path]
Use 1:

mkdir a

- The above command creates a new directory called a.

Use 2:

mkdir \a\b\c

- First, it creates a new directory 'a'. After creation, it creates directory 'b'. and finally, it creates directory c. c directory which is subdirectory of b. Whereas b is a subdirectory of a.

Use 3:

md a

The above command creates a new directory called a.

Use 4:

md \a\b\c

First, it creates a new directory 'a'. After creation, it creates directory 'b'. and finally, it creates directory c. c directory which is subdirectory of b. Whereas b is a subdirectory of a.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > mkdir a

D:\DINESH > mkdir a\b\c

D:\DINESH > md x

D:\DINESH > md x\y\z

D:\DINESH > _

HELP - Dos Command :

It provides the help information for Windows XP commands.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'help' command with its all possible parameters you can use following command. Its like help information to regarding that command.
help/?
Syntax :
 HELP [command]

where,
command: It displays help information on that specific command.

Use 1:

help
- When, you enter 'help' command then it displays various Windows XP commands.

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > help

Use 2:

help time
- When, you enter 'help' command for 'time' then it provides the information for 'time' with its different passing parameters.

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > help time

FORMAT - Dos Command :

It is used to format or erase information or data from a disk drive.
To view 'format' with its all possible parameters you can use following command. Its like help information to regarding that command.
format/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :

FORMAT volume [/FS:file-system] [/V:label] [/Q] [/A:size] 
 [/C] [/X] 

FORMAT volume [/V:label] [/Q] [/F:size] 

FORMAT volume [/V:label] [/Q] [/T:tracks /N:sectors] 

FORMAT volume [/V:label] [/Q] 

FORMAT volume [/Q] 
where,

volume : It specifies the drive letter (followed by a colon), mount point, or volume name.

/FS:filesystem : It specifies the type of the file system (FAT, FAT32, or NTFS).

/V:label : It specifies the volume label.

/Q : It performs a quick format.

/C --> NTFS only: Files created on the new volume will be compressed by default.

/X : It forces the volume to dismount first if necessary. All opened handles to the volume would no longer be valid.

/A:size --> It overrides the default allocation unit size.

/F:size --> It specifies the size of the floppy disk to format (1.44)

/T:tracks --> It specifies the number of tracks per disk side.

/N:sectors --> It specifies the number of sectors per track.

Use 1:

format C:
- This will delete or erase all your data from C drive.

Use 2:

format c: /q
- It leads to quick format. It erases all data from C drive quickly.

Exit Command :

It quits command prompt(cmd.exe) program or the current batch script.
To view 'exit' command with its all possible parameters you can use following command. Its like help information to regarding that command.
exit /?
Syntax :

EXIT [/B] [exitCode] 


where,

/B : It specifies to exit from current batch file script
 instead of cmd.exe. If executed from outside a batch
 script, it will quit cmd.exe

exitcode : It specifies a numeric number. If /B is
 specified, it sets ERRORLEVEL that number. If quitting
 cmd.exe, it sets the process exit code with that number.
Use 1:

exit

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > exit

ECHO - Dos Command :

It displays messages or turns command echoing on or off.
It is commonly used in a Batch file scripting.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'echo' command with its all possible parameters you can use following command. Its like help information to regarding that command.
echo /?
Syntax :
 ECHO [ON | OFF]
 ECHO [message]
Use :

p1.bat

echo off
echo dinesh
echo technoexam.com
echo tforteach.com
echo on
echo "After making echo on !"
pause

The above batch file script when execute, it executes commands one-by-one. When Echo gets OFF then it does not Echo commands on the screen.

Output :


D:\ > echo off
dinesh
technoexam.com
tforteach.com

D:\ > echo "After making echo on !"
"After making echo on !"

D:\ > pause
Press any key to continue . . . _

DEL / ERASE - Dos Command :

It is used to delete one or more files.
You can use Del command or Erase command to perform deletion operation.
To view 'erase or del' command with its all possible parameters you can use following command. Its like help information to regarding that command.
erase/?

OR

del/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :

 DEL [/P] [/F] [/S] [/Q] [/A[[:] attributes]] names 
 or  ERASE [/P] [/F] [/S] [/Q] [/A[[:] attributes]] names

where,

names: It specifies a list of one or more files or directories. If a special kind of directory is mentioned then all files within it will be deleted. Here, wildcards can be used to delete multiple files.

/P : It prompts for confirmation before deleting each and every file.

/F : It forces deleting of read-only files.

/S : It deletes specified files from all subdirectories.

/Q : This is a Quiet mode. It do not ask if ok to delete on global wildcard.

/A : It is used to select files to delete based on attributes.

attributes are:
S - System Files
H - Hidden Files
R - Read-Only Files
A - Files ready for archiving

If command semantics are enabled then DEL and ERASE changes as follow:

The display semantics of the /S switch are reversed in that it shows you only the files that are deleted, not the ones it could not find.

Use 1:

del /p C:\test1
- It deletes files located inside test1 directory only.

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /p C:\test1
C:\test1\green.txt, Delete (Y/N)? y

D:\DINESH > _

Use 2:

del /f C:\test1
- It forcefully deletes files located inside test1 directory only.

Output 2:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /f C:\test1
C:\test1\*, Are you sure (Y/N)? y

D:\DINESH > _

Use 3:

del /s C:\test1
- It deletes files located inside test1 directory and also the other files which are located in sub-directories.

Output 3:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /s C:\test1
C:\test1\*, Are you sure (Y/N)? y
Deleted file - C:\test1\green.txt
C:\test1\test2*, Are you sure (Y/N)? y
Deleted file - C:\test1\test2\green.txt

D:\DINESH > _

Use 4:

del /q C:\test1
- It deletes files located inside test1 directory only without describing any operations.

Output 4:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /q C:\test1

D:\DINESH > _

Use 5:

del /a:r C:\test1
- It deletes files which are having read only attributes from test1 directory only.

Output 5:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /a:r C:\test1
C:\test1\*, Are you sure (Y/N)? y

D:\DINESH > _

Use 6:

erase /p C:\test1
- It erases files located inside test1 directory only.

Output 6:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /p C:\test1
C:\test1\green.txt, Delete (Y/N)? y

D:\DINESH > _

Use 7:

erase /f C:\test1
- It forcefully erases files located inside test1 directory only.

Output 7:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /f C:\test1
C:\test1\*, Are you sure (Y/N)? y

D:\DINESH > _

Use 8:

erase /s C:\test1
- It erases files located inside test1 directory and also the other files which are located in sub-directories.

Output 8:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /s C:\test1
C:\test1\*, Are you sure (Y/N)? y
Deleted file - C:\test1\green.txt
C:\test1\test2*, Are you sure (Y/N)? y
Deleted file - C:\test1\test2\green.txt

D:\DINESH > _

Use 9:

erase /q C:\test1
- It erases files located inside test1 directory only without describing any operations.

Output 9:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /q C:\test1

D:\DINESH > _

Use 10:

erase /a:r C:\test1
- It erases files which are having read only attributes from test1 directory only.

Output 10:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /a:r C:\test1
C:\test1\*, Are you sure (Y/N)? y

D:\DINESH > _

DATE - Dos Command :

It displays or sets the new date.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'date' command with its all possible parameters you can use following command. Its like help information to regarding that command.
date/?
Syntax :
 Date [/T | date]

Use 1:

date
The current date is: Tue 11/08/2011
Enter the new date: (mm-dd-yy) 11/12/2011

- 'date' command without parameters displays current system date setting and it prompts for a new one. You can change system date by entering new date or you can simply press ENTER to keep the same system date.

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > date
The current date is: Tue 11/08/2011
Enter the new date: (mm-dd-yy) 11/12/2011

Use 2:

date /t
Sat 11/12/2011

- 'date' command with parameter /t, which tells the command to just output the current date only, without prompting for a new date.

Output 2:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > date /t
Sat 11/12/2011

D:\DINESH > 

COPY - Dos Command :

It copies one or more files from one location to another location.
To view 'copy' with its all possible parameters you can use following command. Its like help information to regarding that command.
copy/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :
 COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ]
 source [/A | /B][+ source [/A | /B] [+ ...]]
 [destination [/A | /B]]

where,

source : It specifies the file or files to be copied.

/A : It indicates an ASCII text file.

/B : It indicates a binary file.

/D : It allows the destination file to be created decrypted

destination : It specifies the directory and/or filename for the new file(s).

/V : It verifies that new files are written correctly.

/N : It uses short filename, if available, when copying a file with a non-8dot3 name.

/Y : It suppresses prompting to confirm you want to overwrite an existing destination file.

/-Y : It causes prompting to confirm you want to overwrite an existing destination file.

/Z : It copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line. Default is to prompt on overwrites unless COPY command is being executed from within a batch script.

To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).

Use 1:

copy *.* F:
- It copies all files from current directory to F:\ Drive.

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > copy *.* F:
green1.txt
red1.txt
 2 file(s) copied.

D:\DINESH > _

Use 2:

copy green1.txt F:\ /y
- It copies file from current drive to F:\ without prompting to overwrite file if another same file found at F:\ Drive.

Output 2:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > copy green1.txt F:\
Overwrite F:\green1.txt? (Yes/No/All): n
 0 file(s) copied.

D:\DINESH > copy green1.txt F:\ /y
 1 file(s) copied.

D:\DINESH > _

Use 3:

copy green1.txt+red1.txt
- It copies the contents from red1.txt and joins or combines below the contents of green1.txt file.

Output 3:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > copy green1.txt + red1.txt
green1.txt
red1.txt
 1 file(s) copied.

D:\DINESH > _

Use 4:

copy con test.txt
- It creates new blank text file at current directory. After entering this command press Enter then click Ctrl+Z to save work done and it will execute command.

Output 4:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH >copy con test.txt
^Z
 1 file(s) copied.

D:\DINESH > _

COLOR - Dos Command :

It sets the default console background and foreground colors.
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
To view 'color' command with its all possible parameters you can use following command. Its like help information to regarding that command.
color/?
Syntax :
 COLOR [attr]
where,

attr: It specifies color attributes of console output.

Color Attributes / Codes:

Color attributes are specified by 2(TWO) hex digits, the first corresponds to the background; the second the foreground. Each digit can be any of the following values:

0 - Black
1 - Blue
2 - Green
3 - Aqua
4 - Red
5 - Purple
6 - Yellow
7 - White
8 - Gray
9 - Light Blue
A - Light Green
B - Light Aqua
C - Light Red
D - Light Purple
E - Light Yellow
F - Bright White

'color' command sets ERRORLEVEL=1 if an attempt is made to execute the 'color' command with a foreground and background color that are same.

Use 1:

color
- 'color' command with no arguments restores the color what it was when CMD.exe started.

Use 2:

color 2
- 'color' command with 2 as argument sets foreground color as Green and by default Black as a background color.

Use 3:

color 3
- 'color 3' command sets foreground color as Aqua and by default Black as a background color.

Use 4:

color 4E
- When, you use 'color 4E' then it sets Red as a background color and Light Yellow as a foreground color.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > color 4E_

Using Color Command in DOS :
Color command in DOS Fig.: Using Color Command in DOS

CLS - Dos Command :

It clears the screen.
Command can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :
 CLS

Use :

cls

-The above 'cls' command is used to clear the screen when screen is filled with other command execution logs.

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > cd..

D:\ > cls

Output 2:


D:\ > 

CHKDSK - Dos Command :

It checks a disk and displays a status report. It checks for any errors or cross-linked with hard disk drive.
To view 'chkdsk' with its all possible parameters you can use following command. Its like help information to regarding that command.
chkdsk/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :
CHKDSK [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I]
[/C] [/L[:size]]

where,

volume --> It specifies the drive letter (followed by a colon), mount point, or volume name.

filename --> FAT/FAT32 only: It specifies the files to check for fragmentation.

/F --> It fixes errors on the disk.

/V --> On FAT/FAT32: It displays the full path and name of every file on the disk.
On NTFS: It displays cleanup messages if any.

/R --> It locates bad sectors and recovers readable information (implies /F).

/L:size --> NTFS only: It changes the log file size to the specified number of kilobytes. If size is not specified, displays current size.

/X --> It forces the volume to dismount first if necessary. All opened handles to the volume would then be invalid(implies /F).

/I --> NTFS only: It performs a less vigorous check of index entries.

/C --> NTFS only: It skips checking of cycles within the folder structure.

The /I or /C switch reduces the amount of time required to run Chkdsk by skipping certain checks of the volume.

Use :

chkdsk D: /F
- It fixes errors if found on D: drive.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > chkdsk D: /F
The type of the file system is NTFS.
Volume label is Data.

CHKDSK is verifying files (stage 1 of 3)... 
File verification completed.
CHKDSK is verifying indexes (stage 2 of 3)...
Index verification completed.
CHKDSK is verifying security descriptors (stage 3 of 3)...
Security descriptor verification completed.
Windows has checked the file system and found no problems.

  25599545 KB total disk space.
   5801964 KB in 36626 files.
     11540 KB in 2211 indexes.
         0 KB in bad sectors.
    109549 KB in use by the system.
     65536 KB occupied by the log file.
  19676492 KB available on disk.

      4096 bytes in each allocation unit.
   6399886 total allocation units on disk.
   4919123 allocation units available on disk.

D:\DINESH > _

CD / CHDIR - Dos Command :

It is used to display the name of a current directory. Also it is helpful command used to change current directory.
To view 'chdir or cd' command with its all possible parameters you can use following command. Its like help information to regarding that command.
chdir/?

OR

cd/?
Syntax :

CHDIR [/D] [drive:][path]
CHDIR [..]
CHDIR [\]
CHDIR

CD [/D] [drive:][path]
CD [..]
CD [\]
CD
Use 1:

chdir /d "D:\Tutorials\Web\ASP"

- It will change directory directly to "D:\Tutorials\Web\ASP" from another drive's current directory.

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

E:\> chdir /d D:\Tutorials\Web\ASP

D:\Tutorials\Web\ASP > _

Use 2:

chdir..

- It will go back one directory i.e. upto "D:\Tutorials\Web".

Output 2:


D:\Tutorials\Web\ASP> chdir..

D:\Tutorials\Web> _

Use 3:

chdir\

- It will go to root of the current drive. i.e. on D:\.

Output 3:


D:\Tutorials\Web\> chdir\

D:\> _

Use 4:

chdir

- It returns current path of drive.

Output 4:


D:\> chdir
D:\

D:\> _

Use 5:

cd /d C:\Test\Colors\Green

- It will change directory directly to "C:\Test\Colors\Green" from another drive's current directory.

Output 5:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\> cd /d C:\Test\Colors\Green

C:\Test\Colors\Green> _

Use 6:

cd..

- It will go back one directory i.e. upto C:\Test\Colors.

Output 6:


C:\Test\Colors\Green> cd..

C:\Test\Colors> _

Use 7:

cd\

- It will go to root of the current drive. i.e. on C:\.

Output 7:


C:\Test\Colors> cd\

C:\> _
Use 8:

cd

- It returns current path of drive.

Output 8:


C:\> cd
C:\

C:\> _

ATTRIB - Dos Command :

It displays or changes file attributes to Read-Only, Archive, System File, Hidden File.
To view 'attrib' with its all possible parameters you can use following command. Its like help information to regarding that command.
attrib/?
You can check these file attributes as,
> Right Click on File.
> Properties
> You will see Attributes at the bottom of Properties information.
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :
 ATTRIB [+R | -R]  [+A | -A]  [+S | -S]  [+H | -H] 
 [drive:][path][filename][/S [/D]]

where,

+ : Sets an attribute.
- : Clears an attribute.
R : Read-only file attribute.
A : Archive file attribute.
S : System file attribute.
H : Hidden file attribute.
[drive:][path][filename] : It specifies a file or files for attrib to process.
/S : It processes matching files in the current folder and all subfolders.
/D : It processes folders as well.

Use 1:

attrib +R D:\techno.txt
- It sets Read-only file attribute to techno.txt file.

Use 2:

attrib -R D:\techno.txt
It clears Read-only file attribute from techno.txt file.

Use 3:

attrib +A D:\techno.txt
It sets Archive file attribute to techno.txt file.

Use 4:

attrib -A D:\techno.txt
It clears Archive file attribute from techno.txt file.

Use 5:

attrib +S D:\techno.txt
It sets System file attribute to techno.txt file.

Use 6:

attrib -S D:\techno.txt
It clears System file attribute from techno.txt file.

Use 7:

attrib +H D:\techno.txt
It sets Hidden file attribute to techno.txt file.

Use 8:

attrib -H D:\techno.txt
It clears Hidden file attribute from techno.txt file.

Use 9:

attrib +H D:\test\*.txt /S
--- It sets Hidden file attribute to each file which have .txt file extension located in test folder.

Use 10:

attrib -H D:\test\*.txt /S
--- It clears Hidden file attribute from each file which have .txt file extension located in test folder.

Use 11:

attrib +H D:\test\*.txt /S /D
--- It sets Hidden file attribute to each file which have .txt file extension located in test folder also inside other folders.

Use 12:

attrib -H D:\test\*.txt /S /D
--- It clears Hidden file attribute from each file which have .txt file extension located in test folder also inside other folders.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > attrib +R D:\techno.txt

D:\DINESH > attrib -R D:\techno.txt

D:\DINESH > attrib +A D:\techno.txt

D:\DINESH > attrib -A D:\techno.txt

D:\DINESH > attrib +S D:\techno.txt

D:\DINESH > attrib -S D:\techno.txt

D:\DINESH > attrib +H D:\techno.txt

D:\DINESH > attrib -H D:\techno.txt

D:\DINESH > attrib +H D:\test\*.txt /S

D:\DINESH > attrib -H D:\test\*.txt /S

D:\DINESH > attrib +H D:\test\*.txt /S /D

D:\DINESH > attrib -H D:\test\*.txt /S /D

D:\DINESH > _

Properties : for Use 7:
file properties Fig.: Checking File Attributes Properties

AT - Dos Command :

The AT command schedules commands and programs to run on a computer at a specified time and date. The Schedule service must be running to use the AT command.
To view 'at' with its all possible parameters you can use following command. Its like help information to regarding that command.
at/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
At command is an external command.
To execute AT command successfully it is strongly recommended the 'Schedule service' should be running.
Syntax :
 AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]] 


 AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"

where,

\\computername --> Specifies a remote computer. Commands are scheduled on the local computer if this parameter is omitted. id --> Is an identification number assigned to a scheduled command.

/delete --> Cancels a scheduled command. If id is omitted, all the scheduled commands on the computer are canceled.

/yes --> Used with cancel all jobs command when no further confirmation is desired.

time --> Specifies the time when command is to run.

/interactive --> Allows the job to interact with the desktop of the user who is logged on at the time the job runs.

/every:date[,...] --> Runs the command on each specified day(s) of the week or month. If date is omitted, the current day of the month is assumed.

/next:date[,...] --> Runs the specified command on the next occurrence of the day (for example, next Thursday). If date is omitted, the current day of the month is assumed.

"command" --> Is the Windows NT command, or batch program to be run.

Use 1:

at 6:19PM "c:\techno\shutdown.bat"

- This command will execute on 6:19 PM if system is in running mode. It will shutdown PC if the resultant file has code in it.

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > at 6:19PM C:\techno\shutdown.bat
Added a new job with job ID=1

D:\DINESH >_

Use 2:

at /delete

- This command will delete all scheduled jobs set for operations. It will ask for confirmation in the form of Y/N.

Output 2:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > at /delete
This operation will delete all scheduled jobs.
Do you want to continue this operation? (Y/N) [N]: y

D:\DINESH >_

Assoc - Dos Command :

This command displays or modifies file type extensions associations.
It supports on Windows 2000, Windows XP, Windows Vista, Windows 7.
To view 'assoc' command with its all possible parameters you can use following command. Its like help information to regarding that command.
assoc/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :
ASSOC [.ext [=[filetype]]]

where,

.ext : It specifies file extension to associate the file type with.
filetype : It specifies file type to associate with the file extension.

Use 1:

assoc
'assoc' command without parameters displays the current all file associations.

Use 2:

assoc .doc
assoc .exe
assoc .htm

If 'assoc' is invoked with just a file extension, it displays the current file associations for that file extension.
Specify nothing for the file type and the command will delete the association for the file extension.

Output :


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > assoc .doc
.doc=Word.Document.8

D:\DINESH > assoc .exe
.exe=exefile

D:\DINESH > assoc .htm
.htm=htmlfile

D:\DINESH > _

How to create new DOS Batch File?

You can create batch files using any special Editor like Notepad, Wordpad or maybe Notepad++. We prefer using Notepad. Using notepad can lead to get detailed syntax of all DOS commands. Best practice of batch programming can be done using this editor.
Steps for Creating Batch File:
  • Open Notepad.
  • Type your set of desired DOS commands using which you want to control system.
  • Batch File Notepad Editor Fig.: DOS Commands in Notepad
  • Save file as 'file_name.bat'. Make sure that your file name extension is .bat. It will look as follow:
  • DOS Batch File Fig.: Batch File Preview
Now, you can open this file just simply clicking Double click on it. It will execute sucessfully. The above file will delete all .tmp (Temporary files) from root of D:\ drive if existed. There is no requirement to open Command Prompt (cmd.exe).

How to Open and Run Dos Commands using MS-DOS Command Prompt (CMD.EXE)?

Dos Commands can be run or execute using MS-DOS Command Prompt which is cmd.exe. Cmd.exe file which is located at System32 folder.
Before we going to execute DOS Commands we shall learn how to open MS-DOS Command Prompt?
Steps to open MS-DOS Command Prompt / cmd.exe:
  • Click Start
  • Click Run
  • Type 'cmd' (without any quotes).
  • Click OK or Press Enter.
Now, it will open mini black colored window which is known as 'Command Prompt'. Type your own DOS commands here and simply press enter to execute.

MS-DOS History : Timeline :

Microsoft bought QDOS rights from Seattle Computer Products(SCP) for $25,000 on 27th, 1981.

Year Month DOS Family Release Description
1981 April, 11 PC-DOS 1.0 ---
1982 August MS-DOS 1.25 ---
1983 March MS-DOS 2.0 ---
1984 September MS-DOS 3.0 Microsoft introduces MS-DOS 3.0 for the IBM PC AT.It supports for larger hard disk drives.
1984 November MS-DOS 3.1 (Network) It supports for Microsoft Networks.
1986 April MS-DOS 3.2 ---
1987 April MS-DOS 3.3 ---
1988 July MS-DOS 4.0 ---
1988 Nov MS-DOS 4.01 ---
1991 June MS-DOS 5.0 It includes a full-screen editor. A number of bugs required reissue.
1993 August MS-DOS 6.0 Online help through QBASIC. Disk compression and antivirus included.
1993 November MS-DOS 6.2 ---
1994 March MS-DOS 6.21 ---
1994 April MS-DOS 6.22 New DRVSPACE compression.

Introduction to DOS / Batch Programming

MS-DOS icon
Fig.: MS-DOS Icon
  • MS-DOS is a shortform or acronym for 'MicroSoft Disk Operating System'.
  • It was especially created for IBM computers which introduced by Microsoft in 1981
  • It is a single-user, single tasking operating system which primarily uses Command Line Interface i.e. Command Prompt(cmd.exe)
  • It is built for x86-based personal computers.
  • DOS kernal provides different functions for programs like read a character from keyboard, Display it on screen, Accessing files from disk and many more.
  • DOS has a great functionality in it. It allows shell scripting using batch files (.bat).
  • It is non-graphical text user interface.
  • It controls the computer's hardware and provides a best environment for programs to be run.
  • DOS was programmed in Assembly Language.
  • It is available with Multi-Language support.
  • It supports programming languages such as C, Pascal, Batch, QBasic.
  • The type of kernel used in DOS is a Monolithic Kernel.
  • It has a lot of functionality support under greater command