OPERATING SYSTEM
Every computer needs system software to control its peripherals and to accept the commands
from the keyboard. The operating system allows the user or the programmer to enter commands
from the keyboard, which are then converted into the machine codes and interpreted, so that the
computer obeys the instructions given by the user or the programmer. The relationship between
hardware and software is established by system software. The operating system acts as a link between user and the computer hardware. Ultimately a computer system works using binary signals (i.e.1s and 0s). Actually an Operating system hides the complexities of the computer from the user. The operating system means that you do not have to work directly with binary arithmetic. For instance, by simply typing in the command prompt DIR and then pressing the Return key, it will display a list of all files and directories in the current directory. This is all done automatically in response to a simple 3-letter command that both a user and the operating system understand. The Operating System is the program, which provides organized services to the computer user, and the application programs that they wish to use. These services consist mainly of access to the hardware resources such as the disk drives, keyboard, etc.
Different Types of Operating System
Standalone OS Standalone Operating systems are single user OS which are generally used by personal users for desktop applications. E.g.DOS, Windows 3x, Windows 9x, etc. Standalone operating systems can be used as a client or workstation for the Network operating systems.
Network OS They are multi-user and time-sharing Operating Systems. The entire network operating systems also support multiprocessing and multitasking features. E.g.UNIX, Novell, Windows NT, Windows 2000 Server etc.
UNIX: UNIX operating system was formally released by Bell Laboratory, USA in 1975. It is supposed to be the most stable and robust operating system mainly used for mission critical applications.
Novell: Novell NetWare started at the beginning of 1980’s and was quite popular to work with 16-bit applications in the networking environment. It requires a dedicated server to provide service to the network users.
Windows NT/2000 Server: It is a true 32-bit network operating system, which fully supports multitasking and multithreading features. It supports all the 32-bit/16-bit application. It is more integrated with web technologies and is also appropriate for enterprise networks.
Linux: This operating system was first developed by a student as his project work in the universities at Finland. As it was available with the source code, it became a source of research for the programmers’ worldwide. A Linux users groups was formed and they started to enhance the OS with many new features and started gaining its popularity. Now LINUX is more popular as a web server and hosting web based applications.
DISK OPERATING SYSTEM
MS-DOS is one of the most popular system software for microcomputer. MS-DOS is an abbreviation form of the Microsoft Disk Operating System. It is popular operating system software, designed by Microsoft Corporation for the users of IBM and its compatible computers. It is developed for disk drives. It is a Character User Interface (CUI) based operating system. All commands and correct syntax has to keep in mind and all are in Character Form. Operating system is a silent partner when you are using the Computer. It is the translator between the operator and the computer. A computer is nothing but a dead machine without the operating system. Computer cannot be initialized or be ready to work with unless it loads the system files of DOS. Its main function is to establish the relationship between hardware and software and provide an executable environment to the software inside the system. Out of this it also allows user to communicate with computer by the through of commands called DOS commands. Thus, it is interpreter (media) between hardware and software, and provides working environment to the users. It also controls the hardware, such as mouse, keyboard, monitor, printer etc. MS-DOS comprises three essential files for booting the computer. These are:
a) IO.SYS
b) MSDOS.SYS
c) COMMAND.COM
DOS is limited largely due to its age. It was released in 1981 and designed for a very old CPU
like Intel 80x86. It provides character based user interface (CUI) and does not support the advanced OS features like multitasking and multiprocessing. DOS was quite popular till 1995. In 1995 Microsoft released a complete GUI based multitasking / Multithreading Operating system called Windows 95 which included the DOS as its component. The Operating System has three main constituents: -
1. The system files, which are hidden. Their function is to perform such basic tasks as reading the keyboard, displaying characters on the screen, opening and closing files etc.
2. The command interrupter, COMMAND.COM, which reads commands, typed at the keyboard and attempts to obey them. COMMAND.COM has some simple commands built in - these are known as internal commands.
3. A series of utility programs covering functions not handled by the internal commands. There are approximately 52 of these commands, the exact number varies between different versions of MSDOS, ranging from COPY to copy files to EDIT the text editor, and many more.
Basic Terms related to the MS-DOS:
File:
File is the collection of related information. It is an electronic record of any types of information. File is the heart of DOS. All the information are stored under a unique file name. File names are divided into two parts, first part is called the primary file name and the second part is called the extension file name. Primary and extension file name is separated by a period/dot (.).
Rules for writing the file name:
a. The Primary file name cannot have more than 8 characters.
b. Extension file name can have maximum of 3 characters.
c. " / \ [ ] < > + = ; : , ? * { } and blank spaces are not allowed in the filename.
d. Characters (a to z) and numbers (0 to 9) can be used for file name.
e. Punctuation marks ! (sign of exclamation), @ (at symbol), # (Hash-Number symbol), $ (Dollar Sign), % (Percent Symbol), ^ (Caret), _ (Underscore) and & (Ampersand) can be used for the file name.
f. DOS filenames are not case sensitive.
g.Some filenames to avoid: There are some filenames that you should avoid when naming files because your computer reserves them for special uses. AUX, COM1 or COM2 - the internal name of a device connected to a Serial Port. CON - the internal name of data sent to the keyboard or screen. LPT1, LPT2, LST or PRN - the internal names for the printer connected to the Parallel port.
For example:
Chitwan.doc
Rajan.xls
123.txt
Song.mp3
Directory:
Directory is the container of files & sub-directories. It is the partitioned room (space) of the memory. A directory may contain many files and sub-directories. It contains the names of the files, their sizes, last date of modification and address of the file as to where the disk file is residing. One directory always exists on each disk called the “root”. The root directory is denoted by “\” within which other directories can be created. A directory inside another directory is called “sub-directory”. The directory that has sub-directories inside it, is called "parent directory" of those sub-directories. A parent directory is denoted by ".. (double dot)".
Drive and Drive Letter:
All of the storage devices like Floppy Disk, Hard Disk, and Compact Disk are called the Drives.
All of the storage devices are denoted by different alphabets and letters, which are called drive
letters.
Drive Letter
Floppy Disk A: or B:
Hard Disk C: or D: (if partitioned)
CD-ROM D: or E:
Networking Drive F: or G:
DOS Prompt:
It is the main gate of the MS-DOS, from where we can do any types of work. It is denoted by:
A:\> or, C:\> or, D:\> or, E:\> etc. but if you place inside any directory and sub directory then the
prompt appears as: C:\WINDOWS> or, C:\WINDOWS\DESKTOP> ETC.
Wild-Card characters:
Wild cards are commonly used for the quick function for the execution of DOS commands.
Basically the wild cards are “?” and “*”. These both are used with “.” to get different functions. These have been listed as follows:
* : Represent a group of unknown characters.
.* : Represent any unknown extension(s).
*.* : Represent any unknown file name with any extension.
? : Represent a single unknown character.
Some examples of Wild-card characters:
1. DIR *.DOC = Displays all files having doc extension.
2. DIR R*.XLS = Displays all files staring with r and having xls extension.
3. DEL *.CHK = Delete all files having chk extension.
4. TT?.EXE = Represents all typing tutor application files.
Commands:
A command is a set of instructions used to perform a specific task. When a user types a command in command prompt shell and presses the <enter> key, the Operating system command interpreter converts the command into machine language which is processed to give the required result. There are two kinds of DOS commands. They are:
1. Internal Command
Those are internal commands, which can easily understand by an Interpreter file (COMMAND.COM). Internal commands execute immediate because they are built-in for DOS.
Therefore, when DOS is loaded, these commands are ready to be executed. You cannot see these as command names like in external commands because they are not of a file called
COMMAND.COM. Some internal commands are as follows:
DATE TIME DIR CLS DEL OR ERASE EXIT COPY CON COPY REN MD CD RD PROMPT VOL TYPE VER PATH BREAK ECHO PAUSE
2. External Command
External commands are on the disk as program files. The disk drive has to read the files before execution. The files which have .COM, .EXE OR .BAT are known as external files. There are many external files. Some are as follows:
CHKDSK DISKCOPY FORMAT LABEL SYS TREE DELTREE MEM EDIT XCOPY ATTRIB PRINT MORE SCANDISK DISKCOMP
How to start your Computer in MS-DOS mode?
Computer having MS-DOS Operating System:
1. Switch ON the Power Supply.
2. Switch ON the CPU.
3. Switch ON the Monitor.
Then wait until the DOS-Prompt (C:\> or A:\>) does not appear.
Computer having Windows Operating System:
1. Switch ON the Power Supply.
2. Switch ON the CPU.
3. Switch ON the Monitor.
4. Press F8 function key continuously at the time of booting process.
5. Choose “Command Prompt Only” with the help of Arrow Key.
6. Wait until the DOS-Prompt (C:\>) does not appear.
Or,
From Windows Mode:
1. Click on Start button.
2. Click on Shutdown.
3. Choose Restart the Computer in MS-DOS mode.
To get a DOS Prompt with Windows mode:
1. Click on Start button.
2. Choose Program.
3. Choose MS-DOS Prompt and click on it.
Or,
1. Click on Start button.
2. Choose Run.
3. Type Command (or cmd; in case of windows’00).
4. Press Enter Key or, click on Ok.
Internal Commands:
Note : The DOS commands are not case sensitive and . sign indicates the Enter key.
Date:
This command displays system date and lets user to modify it.
Syntax:
DATE.
EX: C:\>DATE.
Time:
This command displays system time and lets user to modify it.
Syntax:
TIME.
EX: C:\>TIME.
Cls:
This command clears the screen.
Syntax:
CLS.
EX: C:\>CLS.
C:\MY DOCUMENTS >CLS.
Dir:
This command displays a list of files and directories in different order.
Syntax:
DIR [DRIVE:][PATH]<Directory Name>.
DIR. : Displays all files and directories at a time.
DIR/P. : Displays all files and directories page by page.
DIR/W. : Displays all files and directories in wide form in five columns.
DIR/AD. : Displays directories only.
DIR/A-D. : Displays files only.
DIR/AR. : Displays Read Only files.
DIR/A-R. : Displays read write files.
DIR/AH. : Displays hidden files.
DIR/AS. : Displays system files.
DIR/S. : Displays all files and directories (sub-directories) of the computer system.
DIR/ON. : Displays all files and directories in ascending order.
DIR/OD. : Displays all files and directories with date of modification.
DIR/OS. : Displays all files and directories with size.
EX: C:\>DIR.
C:\MY DOCUMENTS >DIR.
Prompt:
This command changes the MS-DOS command prompt.
Syntax:
PROMPT (PROMPT OPTIONS).
EX: C:\>PROMPT (ANY TEXT).
C:\>PROMPT CHITWAN >.
Options:
$D : CURRENT DATE
$T : CURRENT TIME
$Q : EQUAL SIGN
$$ : DOLLAR SIGN
$P : CURRENT DRIVE AND PATH
$V : MS-DOS VERSION NUMBER
$G : GREATER THAN SIGN
$L : LESS THAN SIGN
$P$G : ORIGINAL PROMPT
Copy Con:
This command allows user to create a text file.
Syntax:
COPY CON <FILE NAME>.
EX: C:\>COPY CON POKHARA.
Then create a document as your requirement.
Press Ctrl + Z or F6 key to save a document.
Then, Press Enter key to get a prompt.
Type:
This command displays the contents of previous making text files.
Syntax:
TYPE [DRIVE:][PATH]Filename.
EX: C:\>TYPE POKHARA.
Ren or Rename:
This command allows user to change the name of the existing text file by new name.
Syntax:
REN <OLD FILE NAME> <NEW FILE NAME>.
OR
RENAME <OLD FILE NAME> <NEW FILE NAME>.
EX: C:\>REN POKHARA PCC.
Copy:
This command allows user to copy one or more files from one location to another location or
at the same location with a different name.
Syntax:
COPY <OLD FILE NAME> <NEW FILE NAME>.
COPY <OLD FILE NAME WITH LOCATION> <NEW FILE NAME WITH LOCATION>.
EX: C:\>COPY CHITWAN LAKESIDE.
C:\>COPY LAKESIDE A:.
C:\>COPY C:\MYDOCU~1\*.DOC A: .
C:\>COPY A:MEMO.JUN C:\ .
To copy all the files on the diskette to a directory on drive C: called MEMOS, you would type:
C:\>COPY A:*.* C:\MEMOS .
Copying from a Hard disk to a diskette
1. Insert the diskette to which you want to copy into drive A:
2. Type: COPY C:\{pathname}\{filename} A:{filename}.
{pathname} is the directory (path) on drive C: from which you want to copy the file. {filename}
is the name you want for the copy on the diskette. If you do not specify a new name, the file retains
its old name. This could be used to change the name of a file, by copying it and renaming it at the
same time:
COPY C:\MEMOS\MEMO.JUN C:\MEMOS\MEMOCOPY.JUN .
Del or Erase:
This command allows user to delete or erase the existing files.
Syntax:
DEL OR ERASE <FILE NAME>.
EX: C:\>DEL OR ERASE POKHARA.
C:\>DEL OR ERASE *.CHK.
C:\>DEL OR ERASE A:\*.* .
C:\MYDOCU~1\DEL *.DOC/P. (SECTION WISE DELETE)
MD or MKDIR (Make Directory):
This command is used to create a directory.
Syntax:
MD [DRIVE:][PATH]<Directory Name>.
EX: C:\>MD RAJAN.
CD or CHDIR (Change Directory):
This command is used to change the current directory.
Syntax:
CD [DRIVE:][PATH]<Directory Name>.
EX: C:\>CD RAJAN.
C:\RAJAN>
Note: Use CD.. or CD\ to close the existing (all) directories and return into the main drive.
RD or RMDIR (Remove Directory):
This command is used to delete or remove the existing directory (empty only).
Syntax:
RD [DRIVE:][PATH]<Directory Name>.
EX: C:\>RD RAJAN.
Exit:
This command is used to exit from DOS into the Windows mode. It works only if DOS is
loaded from Windows mode.
Syntax:
EXIT.
EX: C:\>EXIT.
C:\WINDOWS>EXIT.
C:\WINDOWS\DESKTOP>EXIT.
Path:
This command allows user to establish the direct connection to the executable program files,
so that we can easily run any executable program files without loading them into the memory from
any location.
Syntax:
PATH=……….
EX: C:\>PATH C:\TYPESHALA.
C:\>TYPSHALA.
C:\>PATH C:\TT.
C:\>TT.
C:\>PATH. (DISPLAYS ACTIVE PATH)
C:\>PATH; . (DISCONNECT ALL PATHS)
Note: Always set path to C:\Windows\Command for using External Dos Commands.
EG: PATH=C:\WINDOWS\COMMAND.
Help (/?):
This sign is used to get any types of help about MS-DOS.
Syntax:
<COMMAND>/?.
EX: C:\>DIR/ ?. (DISPLAYS HELP ABOUT DIR COMMAND)
Version:
This command displays the MS-DOS version currently in use.
Syntax:
VER.
EX: C:\>VER.
Vol:
This command displays the volume label and serial number (if exists) of the disk drive.
Syntax:
VOL <DRIVE NAME>.
EX: C:\>VOL C:.
C:\>VOL A:.
External Commands:
Move (Move.exe):
This command allows user to move the files from one location to another. This command is
also used to rename the directory.
Syntax:
MOVE <SOURCE/S> <DESTINATION>.
EX: C:\>MOVE C:\MYDOCU~1\*.DOC A :.
C:\>MOVE TT TYPING.
Xcopy (Xcopy.exe):
This command is used to copy files and directories from one location to another.
Syntax:
XCOPY <SOURCE FILES> <DESTINATION>.
EX: C:\>XCOPY/S C:\TT A:\TT.
Options:
/S = Copies directories and sub-directories except empty ones.
/E = Copies all directories and sub-directories.
Sys (Sys.com):
This command is used to transfer system files (files those need to start the computer) from
one drive to another.
Syntax:
SYS <SOURCE DRIVE> <DESTINATION DRIVE>.
EX: C:\>SYS C : A :.
A:\>SYS A : C :.
C:\>DIR/AS A: .
Deltree (Deltree.exe):
This command is used to delete (remove) directory and its sub-directories and files at a time.
Syntax:
DELTREE <DIRECTORY NAME>.
EX: C:\>DELTREE TT.
Doskey (Doskey.com):
This command records all DOS Commands into the memory that you have previously used
in DOS-Prompt. So, that you can easily recall them by pressing up or down arrow keys. After Doskey
is installed, you can move the cursor horizontally without deleting the pre-defined command.
Syntax:
DOSKEY.
EX: C:\>DOSKEY.
Doskey is installed message appears. Then you can get the commands, which are recently
used.
Format (Format.com):
It may be an advantage from this point if you have access to a computer. You use the
FORMAT command to format a diskette. Formatting a diskette you have previously used erases any
data on the diskette, so only reformat a diskette if you are very sure you don't need any of the data
on it.
This command is used to prepares a disk for use with MS-DOS. After formatting a disk,
sectors and tracks are created into a new disk. It removes all contents of the disk and creates new
sectors and tracks.
Syntax:
FORMAT <DRIVE NAME/OPTIONS>.
EX: C:\>FORMAT/Q/S A:.
When formatting is complete, and this prompt appears:
Format another (Y/N) ?
Type Y (for yes) to format another diskette, N (for no) to exit from the FORMAT command.
Options:
/Q = Performs a quick format.
/S = Copies the system files on the formatted disk.
Note: you must Format the new disk before use, so that it is capable for storage. Incase of used
disks, it removes all data from them.
Label (Label.exe):
This command displays the disk drive volume label. It also allows to change the volume label
of the disk drive.
Syntax:
LABEL <DRIVE NAME>.
LABEL <LABEL NAME> <DRIVE NAME>.
EX: C:\>LABEL A:.
C:\>LABEL CHITWAN A:.
Attrib (Attrib.exe):
This command allows user to change the attribution of files.
Attribute Function
+H Hide
-H Unhide (Make hidden file visible)
+R Read-only (File can not be overwritten or erase)
-R Read & Write (File may be overwritten or erase)
+S System (Specify file as a DOS system file)
(Only for those files having .Exe, .Com, .Bat extension)
-S Non-System (Removes DOS system file setting)
Syntax:
ATTRIB <ATTRIBUTE> <FILE NAME>.
EX: C:\>ATTRIB +H PCC.
C:\>DIR.
C:\>ATTRIB +R PCC.
C:\>DEL PCC.
C:\>ATTRIB +S TT.EXE.
C:\>TT.
Note: You can easily view the attribution of files by typing ATTRIB.
More (More.com):
This command is used to display the output page by page instead of continuous scrolling.
Syntax:
<COMMAND>|MORE.
EX: C:\>XCOPY/?|MORE.
C:\>DIR|MORE.
Note: | = This sign indicates a pipeline.
Mem (Mem.exe):
This command displays the memory status of the computer system.
Syntax:
MEM.
EX: C:\>MEM. A:\>MEM.
Tree (Tree.com):
This command displays the directory structure of a drive or path. You can use a switch to
display all the files of each sub-directory.
Syntax:
TREE <DRIVE:> <PATH>.
EX: C:\>TREE.
C:\>TREE|MORE.
C:\>TREE C:\MYDOCU~1/F
Note: /F = Displays the files in each sub-directory.
Chkdsk (Chkdsk.exe):
This command checks the drives (including directories, sub-directories and files) for errors,
and provides a disk and memory status report.
You use the CHKDSK command to:
1. Check a disk to see how much space there is available, and how much is in use.
2. Fix some disk errors, such as files that show a non-zero size but that really have no data
in them
3. Display information about the disk, including the total disk space, the number and size of
files.
4. Display how much Random Access Memory (RAM) is available to MS-DOS. (This is NOT
the total memory in your computer!!)
Syntax:
CHKDSK <DRIVE NAME>.
EX: C:\>CHKDSK C:/F/V.
A:\>CHKDSK A:/F/V.
Options:
/F = Check and fixed errors on the disk.
/V = Provides report.
Run CHKDSK occasionally on all your disks to check for errors.
CHKDSK A: /F {ENTER}
Checks the disk in drive A: for errors and fixes any errors it can.
If CHKDSK finds no errors it displays a report like this:
1213952 bytes total disk space
87040 bytes in 3 hidden files
4608 bytes in 6 directories
1078784 bytes in 97 user files
43520 bytes available on disk
655360 bytes total memory
588480 bytes free
If the CHKDSK command reports any errors on the disk, it displays a message such as: xxx
lost clusters found in xxx chains and asks you whether you want to correct the errors.
Type Y (for yes) and the press the {ENTER} key.
NOTE:-This procedure can cause you to lose some of the information on your disk, however,
not fixing the disk can cause you to lose even more!!
Diskcopy (Diskcopy.com):
This command is used to make a duplicate copy of a floppy disk. You must have a disk with
the same capacity as that of the first, which is to be duplicated. If the disk is not formatted,
Formatting while copying…. Will be the message. After copying a diskette, it prompts Copy another
diskette (Y/N)?
Before you run DISKCOPY bear in mind:
?Diskcopy only works if both diskettes are EXACTLY the same type.
?The diskette you are copying FROM is the SOURCE diskette. The diskette you are
copying TO is the TARGET diskette.
?You don't need to format the target diskette - DISKCOPY does it for you.
?DISKCOPY erases any information you already had on the target diskette.
Syntax:
DISKCOPY <DRIVE1 :> <DRIVE1 :>.
EX: C:\>DISKCOPY A : A :.
C:\>DISKCOPY A: B:.
If your computer has only one diskette drive (this is normal!)
DISKCOPY A: A: {ENTER}
Insert SOURCE diskette in drive A:
Press any key when ready...
Insert the source diskette and press any key when ready!
Insert TARGET diskette in drive A:
Press any key when ready...
Remove the SOURCE diskette and insert the TARGET diskette into drive A: and press any
key again.
When copying is complete this prompt appears:
Copy another diskette (Y/N) ?
Type Y (for yes) to copy another diskette, N (for no) to exit from the DISKCOPY command.
NOTE:- Later versions of MS-DOS may ask if you wish to make another copy of the diskette,
this makes another copy WITHOUT having to insert the SOURCE diskette again.
Diskcomp (Diskcomp.com):
You use the DISKCOMP command to check that two diskettes are EXACT copies of each
other.
NOTE:- They MUST both be of the SAME capacity i.e. 720Kb OR 1.44Mb
It is usually used immediately after using DISKCOPY command to ensure that both copies are
the same. It is not used to compare two disks of different capacity. DISKCOMP refers to the original diskette as the first diskette and the copy as the second diskette.
DISKCOPY <DRIVE 1> <DRIVE 2>.
EX: C:\>DISKCOMP A: A:.
C:\>DISKCOMP A: B:.
If your computer has one diskette drive (this is still normal!!)
DISKCOMP A: A: {ENTER}
Insert FIRST diskette in drive A:
Press any key when ready...
Insert the original diskette in drive A: and then press any key.
Insert SECOND diskette in drive A:
Press any key when ready...
Remove the original diskette from drive A: and insert your copied diskette into drive A: and
press any key again.
Compare OK
Compare more diskettes (Y/N) ?
Type Y (for yes) to compare another diskette, N (for no) to exit from the DISKCOMP command.
NOTE:- If the diskettes are NOT identical run the DISKCOPY and DISKCOMP commands
again.
Scandisk (Scandisk.exe):
This command is used to check and repair a disk.
Syntax:
SCANDISK <DRIVE NAME>.
EX: C:\>SCANDISK C :.
C:\>SCANDISK A:.
Options:
/Checkonly = Check disks for errors but not repair it.
/Autofix = Automatically fixed the errors.
Print (Print.exe):
This command is used to send the contents of file to the printer for printout.
Syntax:
PRINT <FILE NAME>.
EX: C:\>PRINT PCC.
Edit (Edit.com):
This command is used to edit the existing text files. You can also make a new file by using
this command.
Syntax:
EDIT <FILE NAME>.
EX: C:\>EDIT PCC.
C:\>EDIT.
Note: After using this command, a blank screen with menu appears. You have to perform all of the options by using this menu. Use Alt key to active the menu and press highlighted character to give the respective command. You can also use the arrow keys to select the required option.
Batch Program (*.Bat):
A Batch File is a small program file containing the list of DOS Commands. This file helps to
perform any task by using the series of DOS Commands with the help of single file name. The file
name for the Batch Program can be given as a DOS file name, but we should have to give a .bat
extension. After making any batch file, you just have to enter a file name at the DOS prompt and
have to press Enter key at once. Batch program speeds up your work when you run it. It saves your time. You just have to remember the file name instead of several DOS Commands. And also you don’t have to retype multiple commands. A batch file is a file containing a sequence of MS-DOS commands. If you find that you are typing one sequence of commands repeatedly, you can save a lot of time by placing the commands in a batch file. Then, by simply typing the name of the batch file, you can make MS-DOS carry out the command sequence, one command at a time, until the end of the batch file.
Creating and running a batch file
One way to create a batch file is to use the COPY command, another is to use EDIT, or any
word processing program that lets you save files as ASCII text. The examples below show you both methods of creating the same file. Suppose for example, you want to create a batch file that:-
- FORMATs a blank diskette
- Copies all the files in the current directory onto that diskette
- Lists the files copied onto the diskette.
C:\>COPY CON COPYFILE.BAT .
FORMAT A: .
COPY *.*.
DIR A: .
Ctrl + Z
Or,
C:\>EDIT COPYFILE.BAT .
FORMAT A: .
COPY *.* A: .
DIR A: .
From the File drop down menu choose Save
From the File drop down menu choose Exit to close the EDIT program.
To run the file:
C:\>COPYFILE .
NOTE:- there is no need to type the extension for MS-DOS to run a file with a BAT, EXE or COM
extension.
- Points to remember about Batch files:
- MS-DOS may still ask you some questions as it runs the batch file.
- The filename must have a BAT extension, so that MS-DOS recognises it as a batch file.
- You can put any MS-DOS commands into a batch file
- Each command in the file must be on a separate line
You can stop a running batch file by holding down the CRTL key and pressing the C key. MSDOS
displays this message,
Terminate batch job (Y/N)?
If you type Y, the rest of the commands are ignored and the MS-DOS prompt appears.
A List of extra Batch file commands:
- REM Makes the following text a REMark and not a command
- ECHO Puts or suppresses output to the screen
- PAUSE Pauses the file and waits for a key to be pressed
- CALL Allows you to CALL and run another batch file from within a batch file
- FOR Used with IN and DO commands IF Used to test IF an input/parameter is equal or
not equal to a given quantity.
- SHIFT Used to SHIFT though a list of given parameters GOTO Used to jump to a given
- place in a batch file, usually used with the IF command.
- @ Used to stop MS-DOS outputting the command line to the screen, valid for one line
only.
Some other examples of Batch Program:
1. C:\>COPY CON TT.BAT
@ECHO OFF
CLS
CD TT
TT
CD..
PRESS, CTRL + Z OR F6.
C:\>TT.
NOTE: This program only works when TT directory already exist on C: Drive.
2. C:\>COPY CON PCC.BAT
@ECHO OFF
CLS
DATE
TIME
PRESS, CTRL + Z OR F6.
C:\>PCC.
3. C:\>COPY CON WORD.BAT
@ECHO OFF
CLS
CD PROGRA~1
CD MICROS~1
WINWORD.EXE
PRESS, CTRL + Z OR F6.
C:\>WORD.
4. C:\>COPY CON TEST.BAT
@ECHO OFF
CLS
MD 123
COPY C:\TT\*.* C:\123
CD 123
TT
CD..
PRESS, CTRL + Z OR F6
C:\>TEST.
Note: If you want to stop a batch program before completing its action, press Ctrl + C key at a time.
Autoexec.bat
MS-DOS always makes (have) a special batch file named Autoexec.bat automatically when it
loaded. It always exists on the root directory of the boot drive (C: or A:). The DOS command in thisfile will executed automatically whenever the computer is started or rebooted. This batch file usuallycontains special configuration and startup DOS commands, but you can also modify it as yourrequirement. For Example: if you want to change the DOS-Prompt, change the prompt as yourrequirement in Set Prompt = option by using Edit Autoexec.bat command. Run Autoexec.bat
program at once. Then, restart your computer. After then, you always get a changed DOS-Prompt
instead of Original one.
C:\>Copy con autoexec.bat
Path=c:\windows;c:\windows\command;c:\pkzip
Prompt=$p$g
Ctrl + Z or F6
C:\>autoexec.
NOTE : If you change the original path then type autoexec at c : prompt and press enter key to
get original prompt and path.