Transcript DOS!

‫گارگاه کامپيوتر‬
‫‪DiskOperatingSystem‬‬
‫تهيه كننده‪ :‬علي برادران هاشمي‬
Why learn DOS?






2
Many tasks must be done at the command
line prompt
Some tasks are accomplished easier and
faster in DOS
Assumption that user “knows” DOS
Internet users use command line similar to
DOS
Career with networks or computer related
fields must know command line interface
Knowing DOS a must if working for A+
certification.
The Kernel



3
The Kernel is the central module of
an OS.
It is the part of the OS that loads
first, and it remains in main memory.
The kernel of MS-DOS is composed of
three files: IO.SYS, MSDOS.SYS,
COMMAND.COM
IO.SYS



4
Sets up your computer for all the basic
input and output it will need to do.
IO.SYS talks with the Computer’s
Hardware and interacts with the
Keyboard and Mouse through the
BIOS.
BIOS is a code that controls basic
input and output and is stored in the
Read Only Memory (ROM).
MSDOS.SYS

Prepares a foundation for DOS, and
provides many basic features of the
operating system.


5
core of DOS and contains DOS diskhandling programs
MSDOS.SYS communicates between
the IO.SYS and the COMMAND.COM
(next).
COMMAND.COM




6
The Command Line Interpreter – The Shell
It causes the command prompt to appear
C:\>
It converts user input into machine
language.
Basic commands, known as internal
commands, are incorporated in the
COMMAND.COM which is loaded in Memory .
Order of Execution

If COMMAND.COM can not find a command in its
internal table of commands, it looks for the
command in other files in the following order:
1st *.COM,


7
2nd *.EXE,
3rd *.BAT
(* Denotes a file name)
If it can’t find a file with any of these extensions,
it searches directories specified in the path in
Autoexec.bat for the *.COM, *.EXE, or *.BAT
files
A command that is executed from a *.COM, *.EXE
or *.BAT file on the hard disk or floppy is an
external command.
Internal Commands


8
These exist inside the COMMAND.COM.
Internal Commands are located in
memory and can be accessed much
faster then External Commands.
External Commands


9
These exist outside of the Kernel,
normally on a storage device.
Because an External Command is
located on a Storage Device, the
computer must locate the command
and load it into
memory. SLOW!
CONFIG.SYS
Whenever a DOS computer boots up, it
reads the CONFIG.SYS file (if it exists)
and executes any commands in it.
 It is mainly used to configure
interaction with the hardware.
 You can enter commands that:
 install drivers for devices, and
 configure the DOS environment,
memory, buffers, etc.. .
10
AUTOEXEC.BAT



11
Stands for AUTOmatically EXECcuted Batch
file, the file that DOS automatically executes
when a computer boots up.
This is a convenient place to put commands
you always want to execute automatically at
the beginning of a computing session
For example, you can set system
parameters such as the date and time, the
path for searching, run certain programs,
etc.. .
CONFIG.SYS
DEVICE=C:\DOS\HIMEM.SYS
DEVICE=C:\EMM386.EXE
BUFFERS=20 (mem for info transfer from and to hard
drive)
FILES=30 (a max of 30 files can be open at the same
time)
REM DEVICE=C:\DRIVERS\MOUSE.SYS
DEVICEHIGH=C:\DRIVERS\MOUSE.SYS
DOS=HIGH
DOS=UMB
REM DOS=HIGH,UMB
LASTDRIVE=Z
STACKS=9,256 (0 or 8-64, 0 or 32-512)
12
AUTOEXEC.BAT
PATH=C:\WINDOWS;C:\DOS;C:\WP;C:\
GAMES;
PROMPT=$P$G
MODE LPT1=COM1
SET TEMP=C:\TEMP
REM C:\DRIVERS\MOUSE.COM
LOADHIGH C:\DRIVERS\MOUSE.COM
WIN
13
Trees and Directory Structure

Manuals often describe directories and
file structures in terms of a tree.
File
Subdirectory
Directory
Root
However, in a File System, the TREE is inverted
14
Root at top, directories, subdirectories and files below
Directory

A Directory is special kind of file used
to organize other files into a
hierarchical structure.
html
Directory
lab

15
A directory contains information on
files located in them, and perhaps
other directories, like a file cabinet
that contains files and other folders.
Absolute Pathnames

An absolute pathname always begins with
the drive letter, e.g. "C:\" or "A:\")


(or
C:\windows\system
The path begins “relative” to where you are
in the current (or working) directory.

Two dots represent the parent directory “above”,
containing your current directory
Use ..\ to move to the parent directory.
 Use
..\..\ to move to the parent of the parent
directory
A relative pathname never begins with a \ (or C:\)


16
\
DOS FILE NAMING


8(characters filename).3(extension)
EXTENSIONS (COMMON USE)
.COM
.EXE
.BAT
.INI
.SYS
.TXT
.DAT
.BAK
.DLL
17
COMMAND FILES
EXECUTABLE FILES
BATCH FILES
INITIALIZATION FILES
SYSTEM FILES
TEXT FILES
DATA FILES
BACKUP FILE
DYNAMIC LINK LIBRARY
DOS FILE NAMING

ILLEGAL SYMBOLS


ILLEGAL NAMES



18
.:,;/\<>|*?
LPT1 LPT2 LPT3 LPT4
COM1 COM2 COM3 COM4
CLOCK$ CON AUX NUL PRN
DOS Drive letters







19
A: Floppy drive
B: Floppy drive
C: Hard drive
D: CD ROM or secondary Hard drive
E: ZIP drive, other external drives
F: ...
Network drives
Total number of logical drives=23
DIR
/A hidden files
/P one screen at a time
/W contents in wide format
/S all subdirectory contents
/B like /P with no header/summary
info
/L unsorted, filenames in lower case
20
DIR STRUCTURE
Path to LAB1.doc
C:\DATA\CLASSES\HARDWARE\LAB1.DO
C
C:\
PROGRAMS
DATA
EXCEL
WORD
CLASSES
EXCEL.EXE
WINWORD.EXE
HARDWARE
LAB1.DOC
21
NETWORKS
LAB2.DOC
GAMES
BUDGET
THISYEAR
EXPENSE.XLS
PASTYEAR
CHANGE, MAKE, DELETE DIRECTORY
CD
CD\
CD..
dir)
CD\PATH
CD PATH
MD
RD
DELTREE
22
DISPLAYS CURRENT DIR
CHANGES TO THE ROOT DIR
MOVES 1 LEVEL UP (parent
CHANGES TO PATH
FROM ROOT TO PATH
MAKE DIRECTORY
REMOVE EMPTY DIRECTORY
DEL DIR AND SUBDIR
DOS WILDCARDS



Locating files with insufficient data
* a group of characters
? one single character




23
C:\>DIR *.EXE all files with exe
extension
C:\>DIR CIS199?.DOC
Using ? and ???
Using *.SYS
ATTRIB
ARCHIVE (+/- A)
READ-ONLY(+/- R)
or
HIDDEN (+/- H)
in the
SYSTEM (+/- S)
C:\>DIR /A:R
C:\>ATTRIB
24
Files to be backed up.
Files cannot be modified
erased
Files will not appear
directory.
DOS system files
DIR Using Attributes
C:\>DIR/A:H or -H(hidden/not hidden files)
C:\>DIR/A:S or -S (system/not system files)
C:\>DIR/A:D or -D(directory only/file only)
C:\>DIR/A:A or -A(files changed/unchanged)
C:\>DIR/A:R or -R(read-only/not read only)
25
COMMAND PROMPT
C:\>PROMPT=$P$G
$P
$G
$L
$T
$D
$Q
$B
$N
$V
$_
26
Current drive and path
Greater than symbol (>)
Less than symbol (<)
Current time
Current date
Equal sign (=)
Pipe sign (|)
Default drive
DOS Version
Enter or line feed
FILE SEARCH PROCEDURES STEPS




1- COMMAND.COM
2- CURRENT DIRECTORY (.COM, .EXE,
.BAT)
3- DIRECTORIES SPECIFIED IN THE
DOS PATH
ERROR MESSAGE

27
Bad command or filename
COPY
COPY SOURCE\FILENAME DESTINATION
COPY CON Commands at the keyboard
CTRL + Z or F6 to end
DISKCOPY diskcopy a: a:
XCOPY
xcopy c:\*.* f:\hw /s/e/v
/s copies subdirectories
/v verifies data
/e copies empty dir /subdir
28
OTHER COMMANDS
RENAME
DELETE
HELP
MOVE
TYPE
Volume
29
ren test1.txt test2.txt
del test2.txt
dir/?
move c:\test3.txt c:\data
type test3.txt
label
FORMAT



C:\>FORMAT A:
C:\>FORMAT A:/s (SYSTEM / BOOTABLE DISK)
C:\>SYS A:

TRANSFERS SYSTEM FILES TO A:



30
COMMAND.COM
MSDOS.SYS (MS DOS) OR IBMBIO.COM(PC
DOS)
IO.SYS(MS DOS) OR IBMDOS.COM(PC
DOS)
FDISK (HARD DRIVE)





31
TAKES PLACE BEFORE FORMAT
MULTIPLE PARTITIONS MAY BE CREATED FOR

ADDITIONAL LOGICAL DRIVES and or

DIFFERENT OPERATING SYSTEMS
CREATES A PARTITION TABLE
IDENTIFY THE ACTIVE PRIMARY (BOOTABLE)
PARTITION
DELETE PARTITION
 CAN NOT DELETE EXTENDED PARTITION WITH
DRIVES DEFINED
BATCH FILES





32
FILES WITH FREQUENTLY USED
COMMANDS
TO WRITE USE EDIT OR NOTEPAD
TO EXECUTE TYPE FILENAME
EXTENSION MUST BE .BAT
TO STOP CTRL+C OR CTRL+BREAK
Command Syntax


The graphical user interface in Windows
operating system uses syntax and rules.
Parameter:


Parameters can be:


33
Information to modify or qualify a command
Variable
Fixed
Using Fixed Parameters
with the DIR Command

Fixed parameter:




34
Referred to as a switch.
Begins with / (the slash).
Slash = forward slash (/).
\ = Backslash.
Redirection

Keyboard:


Screen:




35
Standard output device
Redirection


Standard input device
Changes standard I/O
e.g. Changes output from monitor to somewhere
else (usually file or printer)
Redirection syntax command:
COMMAND > DESTINATION
(Space required on both sides of >)
Redirection (cont.)

Activity—Redirecting



Output to a File
Redirecting output to a file
Redirecting Output to the Printer



36
Can redirect computer output to a file or to
a printer.
To redirect to printer need a local printer.
Printers device names:PRN, LPT1, LPT2
and sometimes LPT3.
DOS commands
Dir
Cd
Copy
Xcopy
Date
Time
Del
MORE
CLS

37
Deltree
Diskcopy
Edit
Fdisk
Format
Ren
Rd
Type

Why batch files?

Minimize keystrokes





38
Automate frequent/consistent procedures
Do not need to interact with computer
while batch files are running
Automate frequent/consistent procedures
Batch files can be run at anytime
No user/computer interaction required
Batch file


A batch file is a normal text file that contains
DOS commands, each one on a separate
line.
String together series of commands
executed sequentially with one command
without human interaction or interruption




39
Must be an ASCII file
Created with Edit, COPY CON, text editor, or word
processor which has “Save as text file” option
Has .BAT extension
Each line in batch file contains only one command
Writing a batch file

A batch file is a program.



Each line in a batch file must contain only one
command.
To run a batch file at the DOS prompt you type the
batch file name, with or without the “.bat” extension.
To write a batch file you must use a program
that creates ASCII text files.


If a file is readable with the TYPE command, it is an
ASCII text file.
Sometimes easier to use COPY CON instead of EDIT to
write simple batch file.


40
Syntax: COPY CON filename
Drawbacks to using COPY CON:

Cannot correct errors once
<Enter> is pressed
Batch file commands
41
Batch file commands (cont.)
42
REM

REM command (remarks)



43
allows user to place comments in file that are
displayed but not executed.
REM allows file to be documented:
Gives explanation of the purpose of a
program Can include name of batch file, last
time it was updated, and author of batch file
Echo

ECHO ON command:



ECHO OFF command:



44

Minimizes screen clutter
User turns off display of command then only see
command’s output
@ECHO OFF


Displays command and the command’s output to
the screen
Is the default value
will not display the words “ECHO OFF” when the
batch file is run.
ECHO OFF
ECHO school
Pause, label, goto

PAUSE: Used to suspend processing of a
batch file.


A message “Press any key to continue...” is
displayed instructing the user to continue.
LABEL:

Used to identify a section in a batch file by placing
a : at the beginning of the the line followed by a
word.


GOTO:

45
:NICE
Used to move to another location of the batch file.
Instead of going to the next line of the script, a
label is used to identify the location to move to.

GOTO NICE or GOTO :NICE
Example (goto)
@ECHO OFF
:begin
ECHO Hello World
GOTO :begin

To STOP a batch file:

46
press Ctrl+C Or press Ctrl+Break
call

CALL:


Used to jump to and run a different batch program from
within another, and then return to the main batch
program.
It does not cause the original program to stop.
@ECHO OFF
ECHO Start of “phone.bat”
CALL at.bat
ECHO End of “phone.bat”
47
C:\>at.bat
school
C:\>phone.bat
Start of “phone.bat”
school
End of “phone.bat”
Replaceable Variables


Replaceable Variables: are used in
batch files to take user input.
We can use any of the replaceable
parameters %1, %2, %3, %4, %5,
%6, %7, %8 and %9 as temporary
holding spaces. %1
%3
C:\> MAKE.bat test hello test3
Batch File
48
%2
IF VARIABLE == TEXT

IF: Provides conditional processing in
a batch file.


If the specified condition is true, the
command that follows is executed.
If a specified condition is not true the
command that follows is ignored, and the
second command is executed.
IF %1 == hello GOTO :right
GOTO :wrong
49
IF EXIST
@ECHO OFF
IF EXIST hello.txt GOTO :yes
GOTO :no
:yes
TYPE hello.txt
GOTO :end
:no
EDIT hello.txt
GOTO :end
:END
50
CHOICE Batch Command



51
CHOICE: Used to request user input
during the execution of a batch file.
Usually displays a prompt that has
characters for the user to choose to
make their selection.
Usually used with ERRORLEVELS.
CHOICE Batch Command (cont.)
@ECHO OFF
ECHO Pick “A” for Ants
ECHO Pick “B” for Bats
ECHO Pick “C” for Cows
CHOICE /C:ABC
If the user picks “A” errorlevel 1 is generated.
If the user picks “B” errorlevel 2 is generated.
If the user picks “C” errorlevel 3 is generated.
IF errorlevel ==3 goto Cows
IF errorlevel ==2 goto Bats
IF errorlevel ==1 goto Ants
:ANTS
ECHO You picked “A”
ECHO You like ants.
GOTO END
52
Any Question?
53