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

Lab 02

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Lab 02

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Learning Some Configuration

Commands and creating


Batch Files in Dos Environment

LAB 02
CONFIGURATION COMMANDS
date Command is used to set date of the system
Syntax: date mm/dd/yy (we can use ‘-’ in place of ‘/’)
Example: c:\>date 5-16-2011 This will set date to May 16, 2011.
Date Demo
time to set time of the system using the 24 hour clock representation
Example: c:\>time 14:33 This will set current time to 2:33 pm.
time Demo
cls to clear the screen
Example: c:\>cls This will clear the screen and bring the cursor to the top.
Cls Demo
Prompt this will change root directory(Prompter value) to what u will write in
command
Example: c:\>prompt neduet: This will set the current prompt to neduet:
U have seen
Prompt value has
Been changed
CONFIGURATION COMMANDS
To get back to standard default system prompt, type prompt without
Parameters or Type Prompt $p (active drive(c) with directory
(remaining path) where we were Standing)

OR
Use the following switches anywhere in the prompt command to incorporate
special information:
1. $t to get the current time as a prompter

2. $d to get the current date

3. $n to get the active drive only excluding directory (unlike Prompt $p)
CONFIGURATION COMMANDS
4. $g(greater) to change prompter to character ‘>’

5. $l(less) to change prompter to character ‘<’

6. $b(bar) to change prompter to character ‘|’

Multiple special information can be displayed at a time.


CONFIGURATION COMMANDS
path to set the default command search path. There is a single default path
memory where u can set multiple default paths writing them as Colon(;)
separated.
Syntax: path drive:\pathname1
Make sure default paths are only set to Run Executable files like bat files
To see default path just type Path

Let say I have a bat file that gives me system information. check Demo of
Path to understand the path concept
doskey is used to Alias any dos command.
Example: c:\>doskey alias = command whose alias we are making
Lets do a simple exercise to understand doskey concept. Alias a command
“dir/w” with command name “ali” and cls command with command name
“clear” (doskey Demo)
CONFIGURATION COMMANDS
Now use UP and DOWN ARROWS to recall commands
ESC clears command line
F7 displays command history;
ALT+F7 clears command history;
F8 searches command history; (see Demo Few more commands)
F9 selects a command by number.

Let say dir/w is in


Second number
In history of
commands

Make sure the Office key is disabled on keyboard or function key is pressed
in laptops; otherwise these keys will not perform the tasks correctly or
accordingly.
CONFIGURATION COMMANDS
Color attributes are specified by TWO hex digits like COLOR ‘1’’2’
-- the first corresponds to the background; the second the foreground. Each
Digit can be any of the following values:

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

c:\>color 1E This will set the background color to blue and text color
to light yellow.
c:\>color This will set the background color to default.
c:\>color 2 This will set the background color to default.
See color Demo
CONFIGURATION COMMANDS
exit to exit from DOS shell
Example: c:\>exit This will close the DOS window
Dos Help Commands
Type help at the command prompt to display DOS Help table of content
Type help followed by the command name is use to view information about a
particular command. Example C:>help copy
C:>help copy can also be written as C:>copy /? Means The command name
can also be followed by /? to view information about a command.
MAKING BATCH FILES
A batch program of a batch file is a text file that contains a series of
commands that DOS carries out when its name is typed at the command
prompt.
AUTOEXEC.BAT file is an example of such files. It is a special batch program
that runs every time you start your computer. It starts necessary programs
and does settings at the startup. To make a batch file, apply the following
steps:
o Open a new text file in an editor (DOS editor, ‘EDIT’ can be used by typing
edit command at the command prompt to open this editor).
o Type DOS commands, which are to be included in the batch program in
this text file. Each command is typed on a different line.
o Save the file with suitable name provided that its extension is bat. For
example, mybatch.bat
Batch Files Commands
echo This command use to print or display output on the scree
An alternate is to insert @ sign before the command.
Example: @dir
If you use echo off, the command prompt does not appear on your screen.
To display the command prompt, type echo on. To prevent echoing of a line,
insert an at sign (@) in front of a command in a batch program.
call This command calls one batch program from another.
Example: Create a batch file named one.bat with command dir/p. Then
make another batch file named two.bat with the following two commands:
call one.bat
Help
Then Finally run two.bat so this will display what one.bat does that is dir/p
with the help commands respective output as discussed

You might also like