Monday, 23 May 2011

Operating Systems - Customising DOS

Config.sys

The config.sys file is a text file which loads device drivers and defines parameters for MS-DOS.
  • device is used to load device drivers
  • devicehigh loads the driver into the high memory area
  • dos defines the area of memory where DOS will be loaded
  • drivparm defines disk drive specifications
  • fcbs specifies the number of file control blocks
  • files specifies the number of files that can be opened at the same time
  • install runs a resident program (TSR - terminate and stay resident)
  • lastdrive defines the number of valid disk drives
  • shell indicates that another command prompt other than COMMAND.COM should be used.
  • stacks specifies the amount of memory reserved for hardware interrupts

Autoexec.bat

The autoexec.bat is a batch file (as denoted by the file extension), a text file which contains a group of commands run one after the other, each command is written on a separate line. 
Some of the following are examples of commands that can be added to the autoexec.bat (any program that runs in DOS can be added to this file):
  • the path command tells MS-DOS the file location where files can be accessed when in another folder.
  • the prompt command sets the type of MS-DOS prompt
  • the doskey command allows you to use the directional keypad to go back through previous commands that have been run.

Creating a start menu

In DOS, Windows 95 or Windows 98 systems it is possible to create a start menu where you can select which devices are to be loaded in DOS and even (as is the case with Windows 95/98) tell the system to start-up in either Windows or DOS. The config.sys and autoexec.bat files (and in Windows the msdos.sysfile) must be modified to allow the selection of DOS and Windows at start-up.
To have the Windows and DOS options on start-up, the config.sys file must be modified as follows:
[COMMON]

FILES=40

Country=044,850,C:\WINDOWS\COMMAND\country.sys

[MENU]

REM *********Start Menu*************************************


MENUITEM=1, Dos


MENUITEM=2, Windows 98

REM ***********OPTIONS*************************************************

MENUCOLOR=15,0

MENUDEFAULT=2 ,4
[1] contents of the config.sys file you wish to use in configuration 1
[2] contents of the config.sys file you wish to use in configuration 2
[COMMON] contains file information config.sys which is common to both configuration 1 and 2.
[MENU] contains the titles of the menu items (here DOS and Windows 98) as well as the menu settings:
  • background colour (here 15) and text colour (here 0)
  • the item (here the 2nd item) is loaded if no item is selected after a set time (here 4 seconds)
Then both configurations after the markers [1] and [2]
The autoexec.bat file must be modified as follows:
goto %config%

:1
autoexec.bat file contents for configuration 1
goto end
:2
autoexec.bat file contents for configuration 2
win
goto end
:end
(items common to both configurations)
explanation of changes made to the autoexec.bat file
The changes made to the autoexec.bat file are not complicated, there are two sections in the file which the system will go to as you previously selected in the config.sys (as the system will execute theconfig.sys first).
If you wish to choose between DOS and Windows you must edit the msdos.sys file. Make sure you remove the read-only attribute, then add or modify the following lines:
[Options]

BootMulti=1

BootGUI=0
then add the line "win" to the end of the configuration corresponding to Windows in the autoexec.bat, which will then load Windows if selected.


Operating Systems - MS-DOS - Tips

Setting the CD-ROM drive

The CD-ROM drive is configured in the config.sys and autoexec.bat system files. The CD-ROM drive device driver must be configured in the config.sys file (even if the device is automatically detected in Windows). To do this, copy the device driver to a folder on the hard drive (in the following example it is called cdrom.sys located in the "cd-rom" folder). Next you must add the line:
DEVICE=c:\cd-rom\cdrom.sys /d:CD001
(CD001 is the name you give to the CD-ROM drive...)
Next the CD-ROM controller (called mscdex.exe must be added to the autoexec.bat by adding the following line:
c:\windows\command\mscdex.exe /d:CD001
(Where CD001 is the name given to the CD-ROM drive and the drive letter that is assigned to the drive is the next letter available, so if you have hard drives D: and E:, and F: is free, then the CD-ROM drive will be assigned the letter F:. If you want to specify the letter to be assigned use the /L:Z option for example.)

Copying a file

There are to commands used to copy files in DOS: copy and xcopy. 
Xcopy is the most useful, and is uses the following syntax:
xcopy source destination (where "source" is the filename and "destination" is the filename or folder name where the file is to be copied)
The entire contents of a folder can be copied by typing the name of the folder for "source". The destination must therefore be the name of a folder, it would be rather difficult to copy a folder (i.e. a group of files) into one single file! 
The "/s" switch is used to copy sub-folders:
xcopy folder1 folder2 /s copirs folder1 to folder2.

Running a program from any folder

The "PATH" environment variable lets you set the folders whose contents may be accessed even if you are working from a different folder. 
Syntax is as follows:
PATH=c:\dos;c:\utils;
The files located in the C:\dos and C:\utils folders may be executed regardless of which folder you are working from. If you have already specified the folders in the environment variable and you wish to add another, you can use the following command:
PATH=%PATH%;c:\folder;
which will add the folder C:\folder to the existing PATH (%PATH%)
The PATH variable has a 127 character limit as the name of variable PATH and the equal sign take up 5 characters already, there are only 122 characters left to specify the folder names
Tip to use this variable effectively make sure to:
  • remove any spaces in the path command
  • delete any rarely accessed folders
  • give folders the shortest name possible

Mapping a folder to a drive letter

Mapping a folder to a virtual drive can be done using the subst command. 
The syntax for the command is as follows:
subst f: c:\example
The folder C:\example will then be accessible as a virtual drive with the letter "F:". This implies that the F: drive is not already assigned to a drive, if so the system returns the error message "syntax error 10". You must change the target drive letter...

Modifying file properties

A file may have several properties which dictate how that file can be used. These properties can be activated or deactivated in DOS using the attib command. 
The syntax for the command is as follows:
attrib +/-a +/-h +/-s +/-r
where + and - activates or deactivates the attribute which follows.
  • a: archive attribute
  • h: hidden file attribute (the file remains hidden in normal file view)
  • r: read-only file attribute (the file cannot be deleted without deactivating this attribute)
  • s: system file attribute (important files which must be treated with care)
"attrib config.sys -a -r +h" deactivates archive and read-only attributes and hides the file.

Listing files

The dir command is used to list files. The file listing can also be done using several criteria (alphabetical order, date, etc.), these criteria can be applied using the following parameters:
  • /p: fills the screen with the results then pauses the screen
  • /w: displays the results in 5 columns
  • To display files according to various criteria:
    • /ah: displays hidden files
    • /ad: displays folders only
    • /ar: displays read-only files
    • /aa: displays files ready to be archived
    • /as: displays system files
  • To display files in a specific order:
    • /ON: sorted by name
    • /OS: sorted by size (ascending)
    • /OE: sorted by extension
    • /OD: sorted by date
    • /OG: sorted by parent folder
    • /OS: sorted by attribute
  • /s: displays the files located in a folder and all sub-folders
  • /b: minimal view
  • /l: displays results in lowercase
  • /v: displays additional information

Using wildcard characters

For a command that runs on files, instead of giving a file name you can use the wildcard characters when specifying files whose name begins with certain characters:
  • the wildcard character "*" replaces parts of a name or an extension
  • the wildcard character "?" replaces a character (like the blank tile in scrabble)
Thus the command "dir *.com" lists all files with the .com extension. 
The command "dir b*.*" returns all files whose name begins with b.

How to send the displayed results to a file

Using the redirect parameter (> or >>) you can send the results of a dir command to a file:
The "dir >> test.txt" will send the list results to the test.txt file which will be created in the current directory if it does not already exist, or if it does exist the new file name will be concatenated (a number added to the end of the existing file).

No comments:

Post a Comment