0% found this document useful (0 votes)
35 views

Windows Dos Commands

The document provides information about various DOS commands used in the Windows command prompt. It describes commands like DATE, TIME, PATH, COPY, TYPE, FIND, ECHO, SET which are used to view or set the date and time, view the system path, copy files, view file contents, search for text in files, display messages, and set environment variables respectively. It provides the syntax and examples of using each command.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Windows Dos Commands

The document provides information about various DOS commands used in the Windows command prompt. It describes commands like DATE, TIME, PATH, COPY, TYPE, FIND, ECHO, SET which are used to view or set the date and time, view the system path, copy files, view file contents, search for text in files, display messages, and set environment variables respectively. It provides the syntax and examples of using each command.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

WINDOWS DOS COMMANDS

What is a command prompt?


• Command Prompt is a command line interpreter application available
in most Windows operating systems. It's used to execute
entered commands.

• Command Prompt is officially called Windows Command Processor,


but it's also sometimes referred to as ​the command shell or cmd
prompt, or even by its filename, cmd.exe.
What is a command prompt?

Command Prompt can be found in the Start menu or Apps screen,


or use the Run command cmd.
Date command
• The date command can view or change the current date of the
system clock.

• Syntax

Simply type date on command prompt.


How to turn off user account control?
• Type regedit in run.

• Then Go to:
• Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\Policies\System

• Go to Enable-LUA and type Value 0 and then click ok.


Time Command
• TIME with no parameters will display the current time
and prompt for a new value.

• Pressing ENTER will keep the same time.

• Syntax

• time

• time/t: Will not prompt for a new time to enter.


Help command
• Execute the help command without options to produce a list of
commands that are usable with the help command.

• The help command is a Command Prompt command that's used to


provide more information on another command.
Help command
• Syntax

• help

• help dir
md command
• Make Directory - Create a new folder/directory.

• Syntax

md [drive:]path [[drive:]path...]
md command
• Examples

• md fg

To make multiple directories with a single command

md alpha beta gamma

To create a subdirectory within a directory

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

• cd Name of the new directory to be changed as present working directory.

• Example
• cd Desktop
rd command

• Remove (or Delete) a Directory.

• Syntax

RD pathname
Or RD /S pathname
Contt..

/S : Delete all files and subfolders in addition to the folder itself.


Use this to remove an entire folder tree.

/Q : Quiet - do not display Y/N confirmation


Examples of rd command
• rd /s a

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

• Copy one or more files to another location.

• Syntax
COPY [options] [/A|/B] source [/A|/B] [+ source2 [/A|/B]...] [destination [/A|/B]]

COPY source1 + source2.. destination [options]


Example
• Copy from a different folder/directory:
COPY "C:\my work\some file.doc" "D:\New docs\newfile.doc“

• Create an empty (zero byte) file:


COPY NUL EmptyFile.txt

• Copy a file in the current folder


COPY source_file.doc newfile.doc
Example
copy “regedit.txt” “MSC IT SYNOPSIS”

This is the way when there is a need to copy in the current folder only.

copy "C:\Users\HP\Desktop\regedit.txt" "D:\My Content“

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

• FIND [/V][/C][/I][/N] string [d:][path]filename[...]


Find command
• /V - Displays all lines not containing the specified string.
/C - Displays only the count of the number of lines that contained a
match in each of the files.
/I - Ignores the case of letters in the string search.
/N - Displays the found line preceded by the relative line number.
Examples : find command
find “g” xx.txt
Display those lines which contain “g”.

find /c "g" "xx.txt“


---------- XX.TXT: 10—Output

find /v "g" "xx.txt“

---------- XX.TXT--Output
Examples : find command
find /i "G" "xx.txt“
Ignore case

Output: ---------- XX.TXT

g
g
g
gg
g
g
g
g
g
gg
Echo command
• Display messages on screen, turn command-echoing on or off.

Syntax ECHO [ON | 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 ^

• Echo kind &beautiful


• This command will only display kind on the command prompt.
Echo
• Echo kind ^& beautiful

• This command will display both echo and beautiful on the command
prompt.

• Echo/?--- will display help


Echo text into a FILE
• The general syntax is:
Echo This is some Text > t1.txt

• Example

• Echo this is me>t1.txt


To create an empty (zero byte) file:

• Echo. 2>EmptyFile.txt

• To display a blank line

• Echo: hit enter


Set command

• Display, set, or remove CMD environment variables. Changes made


with SET will remain only for the duration of the current CMD session.

Syntax
SET variable=string
SET "variable=string"
SET "variable=" SET /A "variable=expression"
SET /P variable=[promptString]
Conttt…

variable A new or existing environment variable


name e.g. _num
string A text string to assign to the variable.
/A Arithmetic expression .
/P Prompt for user input.
Examples of set command
• Type SET without parameters to display all the current environment
variables.

• Set

• Display variables that begin with 'P':


SET p
Examples of set command
• Type SET with a variable name to display that variable.

• 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

• Enter the value of a


•3
• Echo %a%
•3

You might also like