Windows Dos Commands
Windows Dos Commands
• Syntax
• Then Go to:
• Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\Policies\System
• Syntax
• time
• help
• help dir
md command
• Make Directory - Create a new folder/directory.
• Syntax
md [drive:]path [[drive:]path...]
md command
• Examples
• md fg
md “a\b\c”
cd command
• CD (change directory) is a command used to switch directories in MS-DOS
and the Windows command line.
• Syntax
• Example
• cd Desktop
rd command
• Syntax
RD pathname
Or RD /S pathname
Contt..
It will first ask for yes/no confirmation and then delete directory
accordingly.
rd /s/q a
It will not ask for confirmation.
Path command
• If you enter the PATH command without options , the program will
display the currently set path designations.
• Syntax
• path
Chkdsk command
• Short for "check disk," the chkdsk command is a Command Prompt
command used to check a specified disk and repair or recover data on
the drive if necessary.
• Chkdsk also marks any damaged or malfunctioning sectors on the
hard drive or disk as "bad" and recovers any information still intact.
• Syntax
• chkdsk
cls
• The cls (clear screen) command allows users to clear all the contents
on the screen and leave only a prompt.
• Syntax
• CLS
Ver command
• Ver command prints the version of the Windows OS running on the
computer. This command does not have any options/switches.
• Syntax
ver
Copy command
• Syntax
COPY [options] [/A|/B] source [/A|/B] [+ source2 [/A|/B]...] [destination [/A|/B]]
This is the way when there is a need to copy in the current folder only.
This is the way when there is need to copy the file from one drive to
another.
Type command
• In the Windows Command shell, type is a built in command which
displays the contents of a text file. Use the type command to view a
text file without modifying it.
• Syntax
• type [<drive>:][<path>]<filename>
Type command
[<drive>:][<path>]<filename> Specifies the location and name of the file or files that
you want to view. If your <filename> contains spaces,
you must enclose it in quotation marks (for example,
"Filename Containing Spaces.txt"). You can also add
multiple filenames by adding spaces between them.
Type command
• Examples
• type “regedit.txt”
• This command will display the contents of the file “regedit.txt” on the
command prompt.
Type command
• If you display a binary file or a file that is created by a program, you
may see strange characters on the screen, including formfeed
characters and escape-sequence symbols.
• These characters represent control codes that are used in the binary
file. In general, avoid using the type command to display binary files.
find command
• FIND is a filter command (reads from input, transforms it, and outputs
it to the screen, to a file, or to a printer). FIND searches for a string of
characters you enter in the files you name.
• Syntax
---------- XX.TXT--Output
Examples : find command
find /i "G" "xx.txt“
Ignore case
g
g
g
gg
g
g
g
g
g
gg
Echo command
• Display messages on screen, turn command-echoing on or off.
ECHO [message]
ECHO /?
Echo command
• Type ECHO without parameters to display the current echo setting
(ON or OFF).
• Examples
• Echo hi
• Echo hello
Echo
• Command characters will normally take precedence over the ECHO
statement
•
e.g. The redirection and pipe characters: & < > | ON OFF
• To override this behaviour you can escape each command character
with ^
• This command will display both echo and beautiful on the command
prompt.
• Example
• Echo. 2>EmptyFile.txt
Syntax
SET variable=string
SET "variable=string"
SET "variable=" SET /A "variable=expression"
SET /P variable=[promptString]
Conttt…
• Set
• Set a=hello
• Echo %a%
• Hello--output
Contt..
• Set /a b=70 + 8
• 78—output
• Set /p a=Enter value of a—prompts the user