100% found this document useful (1 vote)
1K views631 pages

MSDOS Programming Info

This book is for those who intend to seize the most intimate secrets of modern computer technology. Narration starts with some elementary explanations and examples. Main part presents professional level data with all relevant latest updates.

Uploaded by

pzpanzer101
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views631 pages

MSDOS Programming Info

This book is for those who intend to seize the most intimate secrets of modern computer technology. Narration starts with some elementary explanations and examples. Main part presents professional level data with all relevant latest updates.

Uploaded by

pzpanzer101
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 631

N.G.

Hitrovo

First steps towards system programming under MS-DOS7

2009

UDC 004.451.9dos N.G. Hitrovo First steps towards system programming under MS-DOS7.

This book is for those who intend to seize the most intimate secrets of modern computer technology. In order to be understood easily, narration starts with some elementary explanations and examples, but its main part presents professional level data with all relevant latest updates. These data will be beneficial for both students and teachers on computer technology as well as for computer maintenance staff, system programmers and developers of x86-platform microprocessor equipment.

This book is distributed according to Attribution-NonCommercial Public License of Creative Commons organization ( http://creativecommons.org/ ).

Table of contents
Introduction...... Chapter 1. Let's get acquainted with keyboard......... Chapter 2. Command line. 2.01 Named objects and their names............ 2.02 Paths........ 2.03 Tips on command line parsing syntax.. 2.04 Syntactic marks with command mission... Chapter 3. Internal commands.. Chapter 4. Configuration commands Chapter 5. Selected drivers for MS-DOS7.. 5.01 DOS's system services.. 5.02 National adaptation drivers...... 5.03 Drivers for "mouse" pointing devices........... 5.04 Memory managers........ 5.05 RAM-disk drivers..... 5.06 HDD services... 5.07 Interface controllers' drivers. 5.08 Services for installable file systems.......... 5.09 Drivers for optical disc drives...... Chapter 6. Selected utilities for MS-DOS7.. Chapter 7. Debugger's assembler commands....... 7.01 Control instructions.. 7.02 Prefixes 7.03 Commands for CPU. 7.04 Commands for arithmetic coprocessor. Chapter 8. Selected interrupt handlers.. 8.01 Interrupt handlers, loaded by PC's BIOS (INT 00 INT 1C).. 8.02 Interrupt handlers, loaded by MS-DOS7 (INT 20 INT 2E).. 8.03 Interrupt handlers, loaded by drivers and TSR programs. Chapter 9. Examples of executable files' composition.. 9.01 Simple configuration files. 9.02 Command files, interpreted by debugger DEBUG.EXE... 9.03 Examples of batch files. 5 10 20 21 25 28 31 36 67 84 85 89 96 100 109 113 117 128 132 137 206 208 211 218 266 291 292 339 387 421 422 428 434

9.04 9.05 9.06 9.07 9.08 9.09 9.10 9.11

Configuration with relocation to RAM-disk.. Examples of simple utilities.. Value assignment to an environmental variable........ Some advices on checking and testing... Let's try to assemble a driver. Exploratory configuration files.. Experiments with linear addressing... MS-DOS7 loading alternatives.....

446 451 455 467 473 480 491 515 528 528 533 544 551 554 561 568 575 578 583 590 596 604 613 619 625

Appendixes....... A.01 Main system data structures. A.02 Keyboard codes and national adaptation.. A.03 Disk access databases.. A.04 I/O control data tables.. A.05 Driver's data structures A.06 Error codes....... A.07 Execution service structures. A.08 Floppy drives data structures.. A.09 Directories and files' data tables....... A.10 Video data tables.. A.11 PC's hardware specifications A.12 Memory allocation and management.... A.13 Formats of hard disk data. A.14 Ports. A.15 CD/DVD service tables........ A.16 Some relevant abbreviations.

Introduction
Nowadays the windows of Windows-2000/XP operating system have become familiar in home interior. You look there for work and for fun. One easily gets an impression of ability to access just everything. But it's a deceptive impression: the actual origin of all computer's wonders can't be seen via these windows. Each advanced user once comes to a sense of a virtual boundary, arranged by the Windows operating system to prevent intrusions into its internal affairs. If you want to understand computer more thoroughly, you have to choose a way leading beyond the familiar windows. But outside the windows there is darkness with no visible fulcrum for support. If you are still eager to go further, then this book is just for you.

0.01

Applied and system software

All computer's wonders are performed by programs. More accurately, there is a complex interaction of applied and system software, each playing its own role. For example, the well-known WORD editor program is a typical application, because it needs run-time environment, provided by the Windows operating system. On the other hand, system software is the one that creates, configures and maintains the operating environment. Much attention is now given to application programming. Microsoft corporation, the owner of Windows operating system, actively promulgates its VISUAL STUDIO packet, comprising several high-level languages for writing applications. Microsoft's interest is obvious: the more applications will require Windows operating system, the more Windows usage licenses will be sold. Attitude to system programming is quite opposite: leading software vendors are determined to prevent any appearance of rival system products. The right to buy some system data is given to reliable business partners only, and not every company can afford such expense. Accepted information policy doesn't foster attention to system programming, but the latter doesn't become less significant because of that. One can't be a true professional in computer technology without some knowledge and experience in system programming. System software is not limited to operating systems only. It also includes hardware drivers, fixed BIOS programs, various diagnostic and recovery services. Study of these software functions has always been an important element of computer technology education. Traditionally system programming is taught on the basis of low-level assembler language (MASM or TASM) under documented versions of Microsoft's DOS (MS-DOS). Now all the documented versions of MS-DOS have become so obsolete, that can't even give access to large storage media used in modern computers. More recent operating sys-

Introduction
tems protect themselves against any attempt of intrusion into their affairs and respond with a known error message "Your program has performed an illegal operation and has to be shut down". Nevertheless an acceptable solution exists. It is an undocumented operating system, which can be installed on modern computers and allows to do just everything. Main purpose of this book is to make you acquainted with that operating system and with it's usage for solving simple system tasks.

0.02

Real mode and protected mode

Protection against execution of inadmissible functions is hardware implemented inside processors (CPU), and it is active while the CPU operates in protected mode. Besides the protection itself, protected mode gives several important advantages, and this is why it has become the main operating mode for modern CPUs. For application programs and for the user the protected mode resembles a virtual shell, disabling all actions, which may inflict any harm to vital functions of operating system. This is the main factor of high reliability, inherent to modern operating systems. Contrary to the protected mode, real mode is a "defenseless" mode, making CPU to emulate archaic processor i8086. One may wonder why this obsolete feature is kept supported in each next CPU generation and is not abandoned yet? There is the only reason: real mode is necessary for modern computer systems. First, real mode is required by BIOS: it must have free access to computer hardware for performing the POST tests. Just because of this mission all processors are automatically set into real mode each time the power supply is switched on. Operating systems too can't obtain control over computer's hardware unless protection is disabled, and therefore must start while CPU runs in a "defenseless" real mode. Having got total control over computer, operating systems of the Windows clone prepare protection data structure so that after switching to protected mode the highest privilege level is granted to Windows OS itself, whereas both the user and applications are given the third (the lowest) privilege level. Since then and for ever the user wouldn't be allowed to change this allocation of rights. Because of the same reason all opportunities beyond the limits of Windows' API become inaccessible for the user and for his application programs in protected mode. Nowadays ordinary user's practice doesn't imply experience to act beyond the restrictions, inherent to protected mode. Fundamental concept of modern operating systems is distinction between the user's and system's spheres of responsibility. Excessive user's curiosity is considered destructive and should be suppressed. Protected mode hasn't proved its efficiency against malignant viruses; it provides an effective protection ... against you.

Introduction 0.03 Why MS-DOS 7 ?

If an operating system permits to run applications in real mode, it can't be as stable as those using protected mode. This is the main reason why old-fashioned DOS-like operating systems have been ousted by more modern ones. But ordinary ratings are not valid for emergency services, which often require unlimited access rights. Then the main drawback of DOS-like operating systems turns into their unique advantage. Therefore computer professionals haven't forgotten DOS. All bootable diskettes (reparatory, diagnostic, disk service, etc.) need an operating system and load just DOS. Most part of bootable compact disks is DOS-based as well. Besides all, DOS is the simplest operating system, and just for that it is the most suitable for primary study of system functions. Though DOS is often considered as a real-mode operating system, this opinion is not completely true. Initially DOS works in real mode, but it shouldn't object against mode change and against user's assignment of privilege levels. Only DOS can give you full freedom of action in both real and protected modes. Practical need of real-mode access forces software vendors to continue development of DOS-like operating systems. Independent FreeDOS project slowly advances towards completion ( http://www.freedos.org/ ). One more commercial version of ROM-DOS recently has emerged ( http://www.datalight.com/ ). Some less fresh shareware versions also have found their interested consumers. A lot of drivers are written in order to supply obsolete DOS versions (MS-DOS 6.22, IBM PC DOS 2000, etc.) with new properties, including access to disks with widespread file systems FAT-32 and NTFS. But drivers, not integrated into the DOS's core, give no opportunity to install DOS onto such disks. If you have ever dared to buy a computer without preinstalled commercial operating system, you almost certainly found there a typical DOS prompt and a HDD (hard disk drive) formatted with FAT-32. Most probably neither of the mentioned DOS versions has any relation to that. Computer initialization is usually done with tools, supplied by Microsoft on emergency diskettes for Windows-95/98 operating systems. Formally it is known as "command line only" loading mode. Simple examination reveals, however, that "command line only" mode doesn't resemble the Windows operating system, but rather is a typical version of DOS. Inside almost every file's code on emergency diskette you can find the proof - a string "MS-DOS Version 7...". The 7-th version of MS-DOS is just that Microsoft's undocumented operating system, which is the main subject of this book. For MS-DOS taken from Windows-95 OSR2 release, function INT 21\AH=30h (8.02-22) reports exact version number 07.0Ah, or decimal 7.10. It is just this version which here and forth is referred to as MS-DOS7. MS-DOS7 is not the latest version of MS-DOS. Windows-ME release is based on MS-DOS8. Having been recompiled for modern CPUs, MS-DOS8 became more compact, but has lost compatibility with some 486 CPU clones. Besides this, it doesn't play an active role during loading of Windows-ME and thus is unable to implement different loading

Introduction
schemes. But other features of MS-DOS8 are similar to those of MS-DOS7, so most data in this book are equally true for both. Each exception is explicitly noted.

0.04

What is this book about?

System programming is a vast theme; its narration tends to grow beyond all affordable limits. Therefore this book doesn't pretend to completeness: several large topics (in particular, networks) have been deliberately left aside. Some other items are touched in short, as far as it is enough for comprehension. Chapters 1 - 4 of this book make the reader acquainted with keyboard, with command line composition and with internal commands. These short chapters are addressed to those who had no deal with MS-DOS7 ever before. Chapter 5 describes important drivers for computer's hardware, including the most recent ones, developed by various software vendors during 2004 2008. Chapter 6 presents a survey of selected utilities for MS-DOS7. Special attention is paid to programming instrument DEBUG.EXE the worst documented utility inside the undocumented DOS. Chapter 7 is devoted exclusively to DEBUG's assembler commands. The 8-th chapter describes various services, which can be called for in MS-DOS7 via interrupts. The 9-th chapter presents examples of programming with the tools from Windows95/98 standard release. Examples will help you to write your own interpretable and executable files according to your needs. Presented selection of examples illustrates the scope of opportunities, which can become available in MS-DOS7, if it is properly asked for. The last "A"-th chapter consists of 16 thematic appendixes with a lot of data tables, concerning both MS-DOS7 and AT-compatible PC's. The last 16-th appendix is a vocabulary, explaining the abbreviations used in this book.

0.05

Some more remarks

For a long time leading software vendors inculcate hard selling of operating systems, which inhibit user's access to real mode. But sales of both OS/2 (IBM, 1989) and Windows-NT (Microsoft, 1994) went bad. The next attempt Windows-2000 opened an opportunity to employ DOS's services on disks formatted with FAT-32. As soon as success of Windows-2000 became obvious, Microsoft decided to kill the whole rival Windows-95/98/ME brood. However, this decision doesn't eliminate necessity of real mode and provides no alternative real-mode tools. I suggest to regard this Microsoft's decision as a guarantee that your study of MS-DOS7 today will not go in vain tomorrow due to advent of any better version of MS-DOS. One more challenge to renewal arose in 2002, when Intel has developed and began to produce the Itanium CPU, providing no support for old-fashioned 16-bit machine code. All

Introduction
former real-mode tools, including MS-DOS7, could be turned into trash by forthcoming emergence of new PCs with 32-bit BIOS code, and then this book were not worth writing. Seven years have elapsed since, but the expected marvel hasn't happened. Public PCs with Itanium CPU have not emerged. One has to admit, that preservation of support for 16-bit code in all newer CPUs must be caused by firm reasons. Until these reasons persist, experience in DOS will still be beneficial for you. How to get MS-DOS7 launched? If Windows-95/98 is installed already, just keep the F8 key pressed while PC starts to boot operating system, and you'll get into boot menu; then choose "command line only" option, and you're there. Otherwise you'll have to get a Windows-95/98 emergency diskette, and boot your PC with this diskette. Suitable images of bootable diskettes can be found in many internet sites, for example, in http://www.bootdisk.com/ . Standard loading procedure leaves you with a "raw" DOS's command line. MS-DOS7 may appear much more convenient and friendly, if you'll follow the advices given in parts 6.25 and 9.01 of this book. Part 9.11 suggests some other ways of launching MS-DOS7, including those sharing common disk with Windows OS. This book is not based on legal OEM description of MS-DOS7, since it hasn't been published yet. Author of this book is the only one responsible for all its contents. Despite genuine desire to check every data item, the 100% veracity of data can't be guaranteed: author's resources are not infinite. Besides that, evolution wouldn't stop, it permanently engenders something new. Therefore the author can't admit responsibility for consequences of your actions, even those inspired by this book. Any risk-bearing affair requires some caution and competence. However there is a hope that owing to this book your actions will become competent, effective and safe. Your remarks and corrections concerning this book should be sent by e-mail to [email protected]. Each relevant message will be accepted with gratitude.

Chapter 1

Let's get acquainted with keyboard

For all DOS-like operating systems the main input means is keyboard. Each keystroke invokes execution of at least one preloaded (resident) software module. Sometimes this execution doesn't reveal itself at all, but more frequently it brings about an appearance of the corresponding character on the screen. Several keys (the "hot" keys) may be charged with more complex missions. Resident software modules, which define key's missions, are loaded in memory by either BIOS (Basic Input-Output system); DOS loader from IO.SYS file (active during loading only); the CON device (console) driver from DOS's core; command interpreter (usually COMMAND.COM). This chapter doesn't describe other "hot" key functions, which may be assigned by other TSR (TSR = terminate and stay resident) utilities or file managers: Norton Commander, Volcov Commander, etc. Being loaded later, TSRs intercept some original keyboard functions as most file managers do or substitute with partial (not exact) emulation. Command line presented by file managers is NOT the same as original DOS's command line: a large part of original keyboard functions is intercepted and made inactive. The following text describes functions of the most common "enhanced" keyboard, which usually has from 101 to 108 keys. Evolution of key's functions is shown just as they are activated while loading MS-DOS7. The assumed final stage of this evolution is that implemented by command interpreter COMMAND.COM.

1.01

Keyboard functions of PC's BIOS.

When switched on, computer starts under control of its BIOS system. BIOS loads the INT 09 handler (8.01-09) and thus becomes able to sense keyboard controller calls sent via the IRQ 1 line. Every keystroke is sensed, but only a few keys and key combinations invoke a certain response. Common BIOS versions assign special mission to the following keys and key combinations: Ctrl-Alt-Delete initiates a "warm" reboot. Delete launches BIOS Setup procedure, which enables to set BIOS' parameters (see notes 1 and 2). This function is deactivated after about 2 seconds, so you have to keep the "Delete" key pressed just when computer starts. Pause/Break (or Ctrl-Break) causes temporary stop until any other key is pressed, thus giving an opportunity to read screen messages.

10

Chapter 1: Lets get acquainted with keyboard


Shift-PrtScr sends current screen to printer via LPT1 port. The printer must be ready and must be able to respond properly (those "designed for WINDOWS" or for USB port wouldn't suit!). There is no uniform standard for BIOS' keyboard functions, so they may somewhat differ. For example, the 8-th BIOS version from American Megatrends provides supplementary PC's loading menu, invoked with the F8 key. Nevertheless some BIOS' keyboard functions de-facto have become standard, in particular, these of the DELETE key (note 2) and of the CTRL-ALT-DELETE key combination. Keyboard functions set by BIOS may be deactivated later, just as any software implemented function. In particular, the Shift-PrtScr keystroke combination is often deactivated by embedded software of the video card. Other BIOS' functions may fail because of INT 09 interception, or because of software crash, affecting data in interrupt table (from 0000:0000h to 0000:0400h) or in BIOS memory area (A.01-1). Therefore the most important reboot function in some PCs is hardware duplicated by a RESET button. Note 1: BIOS Setup program may make active some other keys it depends on BIOS version. These keys enable to change some parameter settings, including the one preventing BIOS' logo display. Without BIOS' logo you will be able to see current BIOS messages. Note 2: some (largely obsolete) BIOS versions launch BIOS Setup procedure with F1, F2, F10, ESC keys or with F3-F2, Ctrl-Alt-S, Ctrl-Alt-Ins, Ctrl-Alt-Esc key combinations. Note 3: some models of "enhanced" keyboard, developed in 1990-ties, have a supplementary TURBO key. TURBO-F11 key combination toggles keyboard lock ON/OFF, and TURBO-F12 key combination toggles beeper sound lock ON/OFF. Most modern keyboards have no TURBO key. Note 4: for power supply control via keyboard many keyboard models are equipped with three special keys: POWER, SLEEP and WAKE UP. These keys are intended to be served by BIOS, but their functions are intercepted, in particular, by Windows-XP and by Windows Vista.

1.02

Keyboard functions of the DOS loader

At some moment during PC's loading the BIOS' logo is replaced by the logo of the operating system. This logo change signifies termination of BIOS's loading mission. Since that moment control is transferred to operating system's loader. Both Windows-95/98 and MS-DOS7 operating systems have the same primary loader, contained as a part inside the IO.SYS file. The loader begins its mission with reading parameters stored in MSDOS.SYS file (5.01-01). Then according to these parameters the DOS loader activates for a time some more "hot" keys and key combinations:

11

Chapter 1: Lets get acquainted with keyboard


turns subsequent loading into Safe Mode with WINDOWS' GUI (graphic user's interface) and default settings, ignoring commands in configuration files (CONFIG.SYS and AUTOEXEC.BAT). SHIFT-F5 turns subsequent loading into "command line only" mode with all drivers, but without WINDOWS' GUI. This is in fact loading of MS-DOS7. F6 turns subsequent loading into Safe Mode (just as F5) plus adds network support. F8 invokes display of WINDOWS' standard boot menu and stops further process until user makes his choice. In MS-DOS8 the CTRL key duplicates the function of F8 key. SHIFT-F8 turns execution of configuration files into step-by-step mode; this enables to skip some operations according to the user's choice. The listed key functions in MSDOS7 and MSDOS8 differ from those implemented in previous DOS versions. Activation of the mentioned "hot" keys may be affected by parameters (BOOTDELAY, BOOTKEYS, BOOTMULTI), specified in configuration file MSDOS.SYS (5.01-01). Of course, loading of WINDOWS' GUI can't be performed, when MS-DOS7 is used as a stand-alone operating system, and the GUI software isn't physically accessible. For the time of displaying boot menu the DOS loader activates cursor keys (up, down), the ENTER key and numerical keys (0 9) in the common part of keyboard. NUMLOCK key is activated too; when NUMLOCK is set ON, numerical (rightmost) keypad may be used to choose menu items by number. After the choice is made, all menu keys are deactivated. If the chosen menu item doesn't imply anything else, then the DOS loader begins interpretation of commands from CONFIG.SYS configuration file (example in 9.01-01). During step-by-step confirmation the choice may be made by Y (yes), N (no), ENTER (= yes) and A keys (A = yes for all following lines). Normal (non-step-by-step) execution doesn't produce any effect on the screen, because at that time Window's logo is displayed. However, the logo display may be suppressed by setting the "Logo=0" parameter in the MSDOS.SYS file (5.01-01). Then on the screen you will see rapidly scrolling messages from the drivers being loaded. In order to be able to examine these messages carefully, you may suspend loading process with a PAUSE/BREAK keystroke or with CTRL-S keystroke combination. Then after any other keystroke the loading process will be resumed. Having interpreted all the lines in CONFIG.SYS configuration file, the DOS loader deactivates all its "hot" keys and transfers control to command interpreter COMMAND.COM. Note 1: in version 7.00 of MS-DOS the DOS loader activates the F4 key in order to start previous DOS version loading. Since version 7.10 of MS-DOS this option has been abolished. F5

12

Chapter 1: Lets get acquainted with keyboard 1.03 Keyboard functions during batch file execution.

Control over the PC is given to the main command interpreter when DOS configuration procedure is not finished yet. The first mission of COMMAND.COM is interpretation of commands in lines of the last configuration file AUTOEXEC.BAT (example in 9.01-02). During interpretation COMMAND.COM is quite self-sufficient, but at the same time the user's role is not diminished to zero. If Window's logo display is turned off, then user can monitor current messages. Besides that, command interpreter keeps active some "hot" keys, which enable user to suspend or to stop interpretation of batch command file. Both suspension and stoppage of execution initiate a complex succession of calls (see 8.01-95 for details), involving resident modules of DOS's core as well as those installed by PC's BIOS. Therefore exact action of some "hot" keys may depend on BIOS version. Nevertheless the activated "hot" keys are the same in all AT-compatible computers. The Break/Pause key provides a temporary stop, enables to read messages, but gives no opportunity to terminate execution of batch file: any following keystroke resumes execution. The user can terminate batch file execution with "hot" keystroke combinations CTRL-C, CTRL-BREAK and ALT-03 (the latter digits "03" must be typed via the rightmost numerical keypad). Action of these keystroke combinations depends on the way the command interpreter has been launched. When COMMAND.COM starts permanently with /K or /P parameter (6.04), the mentioned keystroke combinations stop execution and display an offer "Terminate batch job? Y/N" thus providing an explicit choice. But if COMMAND.COM starts with /C parameter (6.04) for execution of a single job (as inside TSR shells), then CTRL-C, CTRL-BREAK and ALT-03 keystroke combinations terminate batch file interpretation at once, giving no chance to resume. The CTRL-S keystroke combination provides a temporary stop, but (unlike the BREAK key) always enables to have a choice. You may resume execution by pressing any other key, except CTRL-C, CTRL-BREAK, ALT-03 and CTRL-2. Action of CTRL-C, CTRL-BREAK and ALT-03 depends on the way COMMAND.COM has been launched just as it was described above. CTRL-2 acts similarly, but only when execution has been suspended already by CTRL-S. Normal batch interpretation will not be affected by CTRL-2 keystroke combination. Keyboard functions, breaking interpretation of a batch file, can be disabled by CTTY NUL command (see 3.07) in a line of the same batch file. But this trick may be justified in special circumstances only (example in 9.03-02).

13

Chapter 1: Lets get acquainted with keyboard


Having finished interpretation of commands from AUTOEXEC.BAT file, command interpreter COMMAND.COM by default must transfer control to the Windows' GUI loader - the WIN.COM file. But this wouldn't happen, if the WIN.COM file isn't found (for example, on a bootable diskette); the SHIFT-F5 key combination has been pressed at start (1.02); in Windows' boot menu the "command line only" option has been chosen; in MSDOS.SYS file (5.01-01) the "BootGUI=0" parameter is specified; the SINGLE parameter is given to the DOS command (note 1 to 4.08). In any of the listed cases MS-DOS7 is loaded instead of the Windows operating system, command interpreter COMMAND.COM begins to accept commands from keyboard, displays its prompt on the screen, and since that moment works with keyboard in a quite different way.

1.04

Keyboard input of commands and textual lines.

When COMMAND.COM presents its command line, it accepts input via the CON device driver. The latter enables to type characters, digits and special symbols according to keyboard layout table resident in memory. Symbols may be entered either by corresponding keys or by ASCII decimal symbol's numbers. The latter should be typed via numerical keypad while the ALT key is kept pressed. Each next character appends the current command line and increments by 1 current position pointers for the current line and for the internal memory buffer, where the previous line is automatically stored. Selection of symbols, typed with literal keys, depends on the state of SHIFT and CAPSLOCK keys. Pressing CAPSLOCK toggles keyboard into upper case letters selection and back. Pressing SHIFT turns keyboard into upper case selection for a while until SHIFT key isn't released. Besides that, DOS presents some limited opportunities of editing current command line (1.05). All mentioned features are equally true for typing textual lines. Transition from command line input to textual line input is initiated by an explicit request to the CON device driver, for example, with command COPY CON Filename.txt where FILENAME.TXT is an arbitrary name of a file to store the text. The COPY command is not a separate utility; it is an internal command of the interpreter COMMAND.COM (3.06). Textual line input also can be implemented by other utilities, which are able to address the CON device driver in the same way. Differences between textual input and command line input evince in what happens with the typed line when user confirms that typing the line is finished with the ENTER key-

14

Chapter 1: Lets get acquainted with keyboard


stroke or with equivalent CTRL-M keystroke combination. Textual lines are written into an internal buffer, replace there the previous line, and then a new line is opened for input. The end of each textual line is marked with bytes 0Dh 0Ah, and in this form it is appended to previous lines in memory area, devoted for text storage. The COMMAND.COM interpreter enables to send this text into a specified file or into a selected channel (see 3.06 for details). Return from textual input back to command line input can be performed with keystroke combinations F6-ENTER, CTRL-Z-ENTER or ALT-26-ENTER. In the latter combination the digits must be typed via the rightmost numerical keypad. When the ENTER keystroke signifies entering of a command line, this line is also written into an internal line buffer, just as textual line, but the following events occur otherwise. In buffer the line is parsed in order to extract the command name and to discriminate whether it is an internal command or a separate utility. While parsing MS-DOS7 regards upper case letters and lower case letters as identical. Separate utilities are searched for (2.02-02), read from their media and prepared for execution. When execution terminates, control is returned back to command interpreter. The latter displays it's prompt in a new line and begins to wait for the next command line input. If the main object of the parsed line is a name of a command file, then command interpreter begins to read commands from this file and interprets them line-by-line. When execution of the last command line terminates, command interpreter returns to waiting for command line input from keyboard. Specific contents of a command line, of course, depend on the command interpreter it is addressed to, and this is a subject of a separate consideration, which begins in chapter 2 of this book and is continued along all the following chapters.

1.05

Functional keys for line editing.

The most "hot" input key, no doubt, is the ENTER key. But besides it there are several other "hot" keys, charged with editing and control functions, which have a long history in former computer generations. Both interactive command interpreters in DOS COMMAND.COM and DEBUG.EXE inherit these functions. Some of them seem rudimentary, but some are still widely used. BACKSPACE key (left arrow) decrements by 1 current position pointer for the current line and in internal memory buffer as well. Contents of internal memory buffer remain intact, but the last character in the current line looks lost; in fact this character is prepared to be overwritten with the following keystroke. Left arrow among cursor keys, left arrow in the numerical keypad, CTRL-H and ALT-08 keystroke combinations do just the same.

15

Chapter 1: Lets get acquainted with keyboard


CTRL-2, CTRL-C, CTRL-BREAK and ALT-03 all these key combinations erase contents of the current line and open an empty line to be typed anew. All previous textual input becomes lost. CTRL-ENTER, CTRL-J, and ALT-10 key combinations wrap current input line and give an opportunity to continue it in the next lower row. This enables to see the whole line (up to 128 characters long by default) within the screen, which is usually 80 characters wide. The wrapped command line is always accepted just as if it were continuous. CTRL-G and ALT-07 key combinations insert code 07h "Beep". It does nothing in textual and command lines, but having been sent to the screen, produces a vile sound signal instead. CTRL-P and ALT-16 key combinations toggle data output from screen to printer and back. This is dangerous when printer is not ready, or is not connected, or is connected not to the default port (LPT1). In any such case INT 24 (8.02-84) is called for with its "Abort, Retry?" offer, but the "Abort" choice doesn't reset the output state (this seems to be a bug). In order to get back to normal command line you have to press CTRL-P once more, otherwise the offer is repeated indefinitely. DEL (DELETE) key increments by 1 the pointer in internal memory buffer. This looks as though the previous line in the buffer has been shifted one position to the left. If then copying into the current line is performed, one character from the preceding line becomes skipped. Formerly this function was known as "SKIP1". ESC, CTRL-ESC, CTRL-[ and ALT-27 key combinations cancel the current line and open a new one. Formerly this function was known as "VOID". Contents of internal memory buffer remain intact. The cancelled command line is marked on the screen with a backslash "\", but the backslash itself doesn't cause the "VOID" action: you are free to type it in an ordinary way. F1 keystroke appends the current line with one character, copied from the same position in the previous line, which is kept stored in internal memory buffer. Formerly this function was known as "COPY1". Right arrow key in numerical keypad and right arrow cursor key do just the same. F2 keystroke causes a pause, waiting for one character input. If the inputted character isn't present in the rest part of previous line in internal memory buffer, the F2 keystroke is aborted; but if the character is present, a number of characters preceding the inputted one are copied from internal buffer, appending the current line. Formerly this function was known as "COPYUP". F3 keystroke fills line's empty space with characters from internal memory buffer, thus copying the previous command line. If current line contains several symbols already, then only the rest part of characters from inter-

16

Chapter 1: Lets get acquainted with keyboard


nal memory buffer will be appended to existing part of the current line. Formerly this function was known as "COPYALL". F4 keystroke affects internal memory buffer only. When pressed, F4 causes a pause, waiting for one character input. If the inputted character isn't present in rest part of internal memory buffer, the F4 keystroke is aborted; but if the character is present, preceding characters in memory buffer are deleted. This looks as though the contents of internal buffer became shifted to the left until the inputted character gets the same position as the cursor in the current line. The F4 function, formerly known as SKIPUP, enables to skip a part of preceding line from being copied into the current line by F1 or by F3 keystroke. F5 keystroke copies the current line into internal memory buffer, closes the copied line on the screen with "@" symbol, and opens a next (empty) command line, which is to be typed anew. The described action isn't caused by symbol "@" itself, so the latter may be used in an ordinary way. F7 and ALT-00 insert code 00h, marked by symbol pair ^@. Code 00h interrupts parsing of command line: all characters after 00h will be ignored. But 00h doesn't interrupt text input: code 00h itself and all the following characters remain in the saved text. INS (INSERT) keystroke toggles a bit (see A.02-3, 0040:0017), which controls incrementation of current position pointer in internal memory buffer. If you have copied a part of previous line, then stop incrementation, type in some new characters, and then copy the rest part of previous line, the result will look as if the new characters were inserted between adjacent characters of the previous line. To restore normal incrementation you have to press the INS key once more. CTRL-I, ALT-09 and TAB keys insert code of horizontal tabulation 09h, which is expanded by the displaying procedure into 8 empty spaces. When text is saved into a file, tabulation symbol is not expanded. Some text editing programs can expand the 09h code into other number of spaces. The listed original key functions are often intercepted by TSR (terminate and stay resident) programs, which can be loaded later. TSR shells (Norton Commander, Volcov Commander, etc.) usually intercept INS, DEL, F1 F7 and several other keys, make them inactive or active in another way (see 6.25 for examples). Nevertheless original command line editing functions always remain active for input of textual lines and in DEBUG's (6.05) interactive sessions as well.

17

Chapter 1: Lets get acquainted with keyboard 1.06 Keyboard layouts and character sets.

By default MS-DOS7 employs American English (US') set of characters, represented by codepage 437, but gives an opportunity to replace it according to national demands. Implementation of this opportunity involves several operations for changing both keyboard and display settings. Microsoft proposes the following sequence of operations: change limitations for names and some other setting by loading data from COUNTRY.SYS file (5.02-01, an example in 9.01-01); prepare a memory place for additional codepage(s) by loading DISPLAY.SYS driver (5.02-02, an example in 9.01-01); launch MODE.COM utility in order to load codepages and to make one of them active (6.18, an example in 9.01-02); launch KEYB.COM driver in order to load alternative keyboard layouts (see 5.02-04, an example in 9.01-02); load NLSFUNC.EXE driver (5.02-03) in order to enable switching between prepared codepages and national data sets. National codepages inside WINDOWS-95 OS release are packed into four data files: EGA.CPI, EGA2.CPI, EGA3.CPI, ISO.CPI. Each national codepage contains 256 characters in two character sets: american english set (characters 32 127) and a national one (characters beyond the 128-th). Therefore switching between any national language and english language doesn't require swapping of codepages, it can be performed within any single national codepage. This is quite enough for all that limited variety of tasks, which are solved nowadays with MS-DOS7. Because of this reason swapping of codepages has come out of use. Switching between different character sets (inside one codepage) is done with "hot" keys, arranged by KEYB.COM (5.02-04) or by any other keyboard driver (for example, KEYRUS.COM, see 5.02-05). In particular, KEYB.COM activates CTRL-rightSHIFT key combination for switching to a national character set and CTRL-leftSHIFT key combination to switch back to common english character set. KEYRUS.COM enables to activate various key combinations, including the mentioned ones. Microsoft supplies keyboard layout tables packed in special keyboard data files KEYBOARD.SYS, KEYBRD2.SYS, KEYBRD3.SYS. Among these the KEYBOARD.SYS is the only keyboard data file supporting typewriter form of keyboard layout. Details concerning the choice of a proper keyboard layout for a particular country (and of a proper code page too) are shown in appendix A.02-2. An implementation example of Microsoft's proprietary national adaptation is shown in articles 9.01-01 and 9.01-02. Though Microsoft's keyboard files and codepages include national data for the most part of the globe, they are no more supported by Microsoft and are not opened for updating. Because of this at least 5 other keyboard drivers have been developed for DOS up to now. Only one of those alternatives is described in this book the KEYRUS.COM driver

18

Chapter 1: Lets get acquainted with keyboard


(5.02-05). Contrary to most other keyboard drivers, KEYRUS.COM is an open project, supplied with means for creating new keyboard layouts and for making corrections in codepages. Unfortunately, format of Microsoft's keyboard data files and codepages can't be accepted by KEYRUS.COM. Examples of national adaptation with KEYRUS.COM are shown in articles 9.04-01 and 9.09-01.

19

Chapter 2

Command line

Command line in MS-DOS begins with a machine-generated prompt and then is implied to be filled with symbols and words, which altogether must be suitable for machine interpretation according to certain syntax conventions. The final ENTER keystroke initializes interpretation of command line by a resident program the command interpreter. Implementation of syntax conventions by different interpreters is not just the same. MS-DOS7 provides 3 interpreters: IO.SYS, COMMAND.COM, and DEBUG.EXE. Each interpreter accepts its own set of commands, described in chapter 4 for IO.SYS, in chapter 3 for COMMAND.COM and in part 6.05 for DEBUG.EXE. Since the loader IO.SYS deals with command lines in configuration files only, the user first encounters command line, presented by COMMAND.COM. The latter is often called resident interpreter, because it is permanently loaded into computer's memory and therefore is always ready to perform commands entered from keyboard. By means of input redirection (see 2.04-02 for details) one can force the interpreter to accept commands not from keyboard, but from command files. Each line in command files is in fact a separate command line. Sending command files via input redirection is the only way to automate execution of command sequences by the DEBUG.EXE interpreter (examples in 9.02). The COMMAND.COM interpreter too can accept commands via input redirection, but it is not the best way to execute command sequences for COMMAND.COM, because it is able to handle a special sort of command files batch files without redirection. From batch files the COMMAND.COM interpreter accepts a number of supplementary commands, which can't be executed from command line or from ordinary command files. These supplementary commands include substitution of dummy parameters and names of variables with their values (2.03-03), search for labels and some other commands (3.02, 3.14, 3.21, 3.27). Here and forth in this book the term "batch files" is applied only to this special sort of command files. Examples of batch files are shown in part 9.03. Configuration file AUTOEXEC.BAT (9.01-02, 9.04-02, 9.09-02) also represents an example of a typical batch file. This chapter describes the most essential conventions, which define command line composition both in separate command lines and in command files. These conventions are common to some extent for all the three interpreters in MS-DOS7. Endemic features of interpreters are presented too. If not specified otherwise, interpretation of commands by the main interpreter COMMAND.COM is implied.

20

Chapter 2: Command line 2.01 Named objects and their names

Each command line addresses one or more objects. An object may be, for example, a separate utility, which is to perform the desired action, or an internal command of command interpreter. The data in command line must be ample enough to identify exactly the addressed object(s). For this purpose inside any common folder identical names of objects are not allowed: all files and subdirectories must be given different names. In order to identify any object outside any particular folder the path to this object is taken into account. The path may be specified explicitly or set by default. The main objects name together with its optional path should be specified the first in command line and may be followed by other items, including name(s) of other object(s), parameter(s), reference(s), syntax mark(s), etc. Each line of command files, presented in part 9.03, can be taken as example of command line. There are objects, however, internal commands, ports and some others which can't be defined by path specification. The names of such objects must be unique, reserved words, which shouldn't be assigned to any other object. Therefore the first theme to consider is which names may be assigned to objects by the user, and which can't. 2.01-01 Reserved words

Reserved words represent names of internal commands, specific for each interpreter, and names of devices, claimed as existing in a particular computer. Names of these objects can't be altered or assigned to other objects. Nevertheless the reserved words should be known in order to prevent attempts to assign such names to other objects, which can be named by the user. Internal commands are those performed by a particular interpreter itself. All those names of internal commands, described in chapter 3, are regarded as reserved words as long as command line is interpreted by COMMAND.COM. For example, you can't assign the name PROMPT to a file, since COMMAND.COM, having encountered this name in command line, "understands" it as its own internal command and has to do nothing but perform this command. Other command interpreters similarly don't allow to assign names of their internal commands to other objects. Reserved names of devices in a PC define sources for obtaining data or targets for sending data. Most known device names are: AUX first serial port COM1 first serial port (equivalent to reserved name AUX) COM2 second serial port CON console, i.e. keyboard for input and display for output LPT1 first parallel port NUL virtual "nowhere" output port

21

Chapter 2: Command line


PRN first parallel port (equivalent to reserved name LPT1)

Besides these some other device names are regarded as reserved: CLOCK$, COM3, COM4, CONFIG$, LPT2, LPT3. These words are reserved by device drivers, integrated into DOS's core, which are loaded always, even if corresponding device is not physically present. The entire list of devices, which are claimed present in your PC, can be displayed by the MEM.EXE utility (6.17), if it is launched with /D parameter. This utility displays a table, and all registered names are shown in its 4-th column. Reserved words are shown shifted by 3 spaces to the right against other names. Several installable software drivers also can be identified by name and reserve words for this purpose. For example, SETVER.EXE driver (5.01-02) reserves word SETVERXX, HIMEM.SYS driver (5.04-01) reserves word XMSXXXX0, EMM386.EXE driver (5.04-02) reserves word EMMXXXX0. Moreover, when you specify an arbitrary identifier for a CD-ROM drive, for example, MSCD001 (see 5.09-01, 5.09-02, 5.09-03), this name becomes registered by DOS as a reserved word. If later you'll try to assign this name to a file, DOS will reject your attempt. 2.01-02 Names and suffixes

Naming and renaming operations most often are applied to directories (3.19, 6.20) and to files (3.24, 3.25), both ordinary and executable ones. Names in DOS consist of no more than 8 characters and may be appended with an extension (suffix) of no more than 3 characters long. Suffix is separated from the name with a dot. When suffix is assigned, but is not required for a particular operation and is omitted, then the dot separator must be omitted too. Both names and suffixes may be composed of letters, digits and several signs, which have no dedicated functional mission in parsing of command lines: number sign ( # ), dollar sign ( $ ), ampersand ( & ), minus ( ), exclamation mark ( ! ), underscore ( _ ) and a few others (2.04-06). Upper case and lower case letters are regarded equivalent in almost all operations, except letters in strings to be compared with commands IF (3.15-02), SEARCH (6.05-16) and FIND (6.14). Since dot ( . ) is used to separate a name from suffix, it is not allowed to be employed as an ordinary character. Other prohibited signs are comma ( , ), colon ( : ), semicolon ( ; ), equality sign ( = ), question mark ( ? ), plus ( + ), left arrow ( < ), right arrow ( > ), asterisk ( * ), pipe ( | ), slash ( / ), backslash ( \ ), and double quotes ( " ). National language symbols also can't be employed, unless restrictions on their usage are taken off by the COUNTRY command (4.05, 5.02-01, A.02-5). Directory names usually have no suffix. Suffixes in names of files are used to indicate file's type or origin. Three suffixes BAT, COM and EXE have special status, since are recognized by the COMMAND.COM interpreter as belonging to executable files. When a

22

Chapter 2: Command line


filename with either of these suffixes is specified the first in command line, COMMAND.COM automatically tries to execute the file's code. If there is something else except valid executable code, the PC most probably would get hanged. These suffixes shouldn't be assigned to files, which are not definitely executable and valid. Assignment of other suffixes is not so critical, but nevertheless should be submitted to common restrictions. File managers are able to link files with certain extensions to devoted applications, for example, files with suffix BAS may be automatically sent for execution to BASIC language interpreter. It's convenient to have every file automatically directed to appropriate program (examples in 6.25-03, 6.25-04). Suffixes also may be helpful for visual recognition of essential file's classes. The list below shows some suffix associations, commonly used in DOS environment. BAK BAT BIN BMP CAB COM CPI DAT DOC DLL EXE EXT GIF HTM INI JPG RAR RTF SCR SYS TMP TXT ZIP archive or old version of a file batch file, interpretable by COMMAND.COM executable file, which requires fixed placement raster image file (Bit-Map-Picture) compressed file for software distribution executable file without a header library file with font data for DOS files with non-textual data of various kind textual file, produced by the WORD editor Dynamically Linked Library of executable codes executable file with control data in header specifications of functional extensions Graphic Image File file written in HyperText Markup language file with initialization data image file, compressed according to JPEG specification compressed archive file, packed by RAR.EXE textual file of Rich Text Format file with command lines, interpretable by DEBUG.EXE system file, either textual or installable temporary file non-formatted textual file compressed archive file, packed by PKZIP.EXE

Associations for a lot of other suffixes can be found in internet site http://www.openwith.org/ .

23

Chapter 2: Command line


2.01-03 Filemasks and wildcards

Question mark ( ? ) and asterisk ( * ) are known as substitution symbols (or wildcards), which can't be employed in names and extensions, but can be used to replace characters in specifications of names and suffixes in command line(s). Name specification with wildcard(s) is a filemask a means to address several files at once. While parsing a command line with a filemask, COMMAND.COM may invoke wildcard expanding function, which searches for filenames, satisfying to the encountered filemask. If such file is found, its name is substituted for the filemask, and then command line with this name is executed. If more than one such file is found, similar procedures are performed sequentially with each of the found filenames. Whether words with wildcards will be interpreted it depends on the command to be executed: some commands invoke a call for the mentioned wildcard expanding function, some commands don't. Generally wildcards are not ignored, but there are some exceptions: wildcards are not expanded by internal commands ECHO, SET, TYPE and IF with equality comparison function (see chapter 3). wildcards in parameters of a batch file are not expanded (it doesn't matter whether the CALL command is used or not); input redirection notation (2.04-02) doesn't expand wildcards; the FOR command (3.13) expands wildcards inside brackets only, but outside brackets wildcards are transferred "as they are" to the command to be executed inside the FOR cycle, and further fate of wildcards depends on that command. Wildcard ( ? ) means a symbol, which induces comparison procedure(s) to give positive response for any single letter or digit. When the ( ? ) wildcard in a filename or in a suffix is not followed by any explicitly specified letter or digit, comparison procedures also give positive response to absence of any symbol in that place. For example, in a command DEL readme.?? the object will match all files in the current directory having name "readme" and not more than two-character suffix: readme.ru, readme.en, readme.f, and so on. Hence the DEL command (3.09) will delete all such files from the current directory. Asterisk ( * ) means a symbol, which induces comparison procedure(s) to give positive response for any number of any following letters or digits up to the end of the word, which may be marked with either a dot or a space. For example, asterisks in command DEL C:\TEMP\*.* match any filename with any suffix, so this DEL command will be applied to all the files inside the specified directory.

24

Chapter 2: Command line


Numerous examples of wildcard usage are shown in 2.02-03, 9.09-02 and in several other batch files in chapter 9. Note 1: whether the attributes will be taken into consideration during a search for files, satisfying to a filemask, it depends on the command to be executed. For example, wildcard expansion by the ATTRIB command (6.01) includes all files without exceptions. Note 2: interpreters IO.SYS and DEBUG.EXE don't accept wildcards. While CONFIG.SYS file is interpreted by IO.SYS, the question mark is treated not as a wildcard, but as a prompt (see 4.06, 4.07, 4.15, 4.16, 4.25).

2.02

Paths

Exact placement of each file on a disk is specified in a certain directory. Numerous directories are usually arranged in a hierarchical structure: each directory of higher rank may contain data not only about files, but also about placement of several lower rank directories (subdirectories). In order to access any file you have to point out the disk and the path that is a directory and the whole chain of subdirectories, leading to the one, which contains exact placement data for this particular file. DOS gives you an opportunity (2.04-01, 3.03) to specify any one particular path as the default path. This path will be stored in internal DOS's data table (A.03-3). Each time you enter a command line without path specification, DOS takes into account the stored default path. The disk and the final directory (subdirectory), specified in the default path, are known as the current disk and the current directory. DOS's prompt (3.22) is usually adjusted to show the current path. 2.02-01 Typical path structure

By default the command interpreter searches for the addressed object in the current directory. If the object must be found in any other directory, object's name should be preceded by a path, for example C:\DOS\MS7\Edit.com where: Edit.com C:\DOS\MS7\ is the addressed executable file; is an example of a path to this file.

The shown path specification directs the search process: first it should be switched to the root of disk C:, there the DOS directory should be entered, then its MS7 subdirectory, and at last in the latter directory the specified executable file should be searched for. If you happen to have other directory structure, you'll have to specify other names, but the principle remains the same: first the disks letter-name, followed by a colon,

25

Chapter 2: Command line


then a chain of directory names, separated with backslashes, and finally a name of the addressed object. Specifications terminated with a backslash are considered in MS-DOS as having no target object and hence not complete. Such paths are either ignored (see 2.04-01) or regarded as not valid, except one special case the path, reduced to a single backslash. Single backslash after a disk's letter-name means a path to the root directory of the specified disk. For example, A:\ means a path to the root directory of disk A. Paths without disks letter-name (for example: \DOS\MS7\Edit.com) are reckoned from the root directory of the current disk, whichever disk is current at the moment. This is important for writing media-independent batch files (9.01-01, 9.04-01, 9.09-01). Single backslash is interpreted as a path to the unnamed root directory of the current disk. Command to change the current directory (3.02) with the following backslash CD \ performs a jump to the root directory of the current disk, whichever it is. When there is no both disk and root specification at the beginning of the path, it is reckoned taking the current directory as the start point. For example, the path DOS\VC4\Vc.com implies that the first subdirectory DOS exists inside the current directory, otherwise an error message will be displayed. 2.02-02 The PATH variable

In order to make command line usage easier DOS provides one more mechanism of path specification via the PATH environmental variable. This mechanism comes into action when 4 conditions are met: command is addressed to the COMMAND.COM interpreter; PATH variable is present yet in the environment; path is not specified in command line; the first addressed object isn't found in the current directory. If all these conditions are met, then DOS will search for the first addressed object along all the paths, which are implied to constitute the value of the PATH variable. The PATH variable should be set beforehand with internal PATH command (3.20). Examples of paths specification with PATH command are shown in 9.01-02, 9.04-02, 9.09-02. Owing to the PATH variable you can call utilities for execution as easily as though these were always present in any directory you may choose. This is convenient, but only

26

Chapter 2: Command line


until it happens to encounter in the current directory a synonymous version-specific utility, belonging to other version of DOS. Then the latter utility will be found first and will fail, leaving an error message. Different approaches to the problem of avoiding such conflicts are discussed in article 5.01-02 and in introduction article to chapter 6. This problem also may be solved by specifying full paths in command files or in configuration files. Examples of such solutions are given in part 9.03. 2.02-03 Dot(s) in path specifications

A dot ( . ) in path specifications is interpreted as an alias for the current directory. Note, for example, the trailing dot, which replaces the target path in the following copy command: Copy /B A:\MyDir\*.* . Sometimes batch files must be written so as to do their job in any current directory (which may be not known beforehand), and then the dot alias is the only allowable replacement for required specification of target path to the current directory. Addressing to the current directory with a dot is also needed when any other (not current) directory will be implied otherwise. Dot as the first symbol of a path statement means that the path should be reckoned taking the current directory as the start point: .\VC4\Vc.com Such path is equivalent to the one without preceding backslash (2.02-01), but nevertheless this form of path may be practical in batch files, because MS-DOS provides no other means to get rid of preceding backslash. One more reason to use commands with preceding dot alias and a backslash is to prevent search for synonymous utilities throughout all the paths, enlisted in the PATH environmental variable, when execution of a synonymous utility may inflict unwanted consequences. Some utilities return directory specifications with final backslash, for example: C:\DOS\MS7\ Such paths are regarded by MS-DOS as invalid, and MS-DOS doesn't provide means to get rid of the final backslash. Appending a dot to such path solves the problem: C:\DOS\MS7\. - this directory specification is regarded valid. Double dot, or dot-dot ( .. ) may be used in any place within path statements just like the single dot, but dot-dot is an alias for the parent directory. If, for example, you are given specification C:\DOS\MS7\ and want to address its parent directory, then the

27

Chapter 2: Command line


C:\DOS\MS7\.. specification is exactly equivalent to C:\DOS. While parsing a path, containing a double dot alias, DOS simply throws out the preceding element of path's chain (the \MS7\ in the last example). DOS doesn't check whether the thrown element exists, whether it represents a file or a directory. This gives an opportunity to address a new file in a directory, unknown beforehand, on a basis of a path to another file, obtained during execution. Examples of such addressing are shown in article 6.25-03. Double dot without any preceding path is interpreted as an alias to the parent directory with respect to the current one, for example, in a command to change current directory (3.03): Cd .. In order to climb two levels up the tree of directories structure, you have to combine double dot twice: Cd ..\.. Some even more complex double dot combinations may be used to navigate and to explore directory trees.

2.03
2.03-01

Tips on command line parsing syntax


Separation symbols

Words in command line are separated with separation symbols: space ( ), comma ( , ), equality sign ( = ) and semicolon ( ; ). Though space is the one most universally used, either of these is ignored at the beginning of command line and will act as separation symbol in parsing operations, including parsing of an object list within the FOR command (3.13). Because of the same reason separation symbols can't be transferred from parameters of command line into internal dummy parameters of a batch file (2.03-03). There are some exceptions, though. Commands SET and IF use equality sign ( = ) in a special way and don't allow to use it for separation. When symbols comma, semicolon or equality sign precede to ECHO command, then displayed part the line will begin just after the separation symbol, including possible preceding spaces and the word ECHO itself. Semicolon ( ; ) is used as special separator in PATH command (see 3.20). The IO.SYS interpreter deals with semicolon otherwise. Being placed first in a line within Config.sys or Msdos.sys file (5.01-01), semicolon is interpreted as a command to jump to the next line, ignoring the rest part of current line (usually containing commentaries). The DEBUG.EXE interpreter in assembler mode deals with semicolon in a

28

Chapter 2: Command line


similar way: it ignores the rest part of a line after semicolon and thus enables to supplement DEBUG's command files with remarks (7.01-05). 2.03-02 A slash

A slash ( / ) in MS-DOS command line specifications is a sign to interpret the following letter (or word) as a parameter. For example, in command DEL C:\TEMP\*.* /P (see 3.07) slash ( / ) forces to interpret the letter P as parameter, inducing a prompt on whether each file in the specified directory should be deleted. Exact place and form of the parameter(s) are specific and must conform to particular command's specifications. Sometimes a slash ( / ) is used within the FOR command as a functional separator, causing conversion of letters in the following word to the upper case (see 3.13 for details). 2.03-03 Percent sign

Percent sign ( % ) in batch files means substitution of the name of a dummy parameter or of a variable with the value of the same parameter or variable. These substitutions are performed before execution of the specified command(s) and redirection(s). Dummy parameters are named with digits from 0 to 9. Value of the 0-th dummy parameter is always the name of the batch file itself; other dummy parameters take their values from the items, specified after the name of batch file in the command line, from which the batch has been started. So %3 ,for example, will be replaced with the third item, following the name of batch file in command line. If several dummy parameters are specified without a space in between, then after substitution their values will be concatenated. Examples of assigning values to dummy parameters are shown in 2.03-04 and in 9.03-01. If total number of words, following the name of a batch file in command line, is less than 3, then the designation %3 of a dummy parameter will be replaced with nothing and disappears without any error message. If total number of words, following the name of a batch file, is greater than 9, then the values of the rest can be accessed after applying a shift to dummy parameter numeration (3.27). There is one exception, though: the Autoexec.bat file (for example, 9.01-02), automatically executed during DOS loading procedure, has no dummy parameters at all, so the CALL %0 command (3.02) doesn't induce its recursive execution. Names of variables must be a single word with a letter (not a digit!) as their first character. Values of variables either are assigned by special command SET (3.23) or are inherited from parent environment, belonging to the program, which has launched execution of the current program (see 6.04). For performing substitution the name of the

29

Chapter 2: Command line


variable in command line must be surrounded with percent signs on both sides (%VAR%, for example). Numerous other examples of command lines with environmental variables are shown part in 9.03. Note 1: if percent sign is to be transferred without substitution, you have to specify it twice ( %% ). During interpretation of command line the doubled percent sign doesn't induce replacement, it is simply transformed into a single percent sign. Note 2: the FOR command (3.13) employs its own local variable; its name outside batch files must be specified with only one (preceding) percent sign. Being used within a batch file, name of that variable needs two preceding percent signs, for example, %%A, because substitution shouldn't be performed in advance to the FOR command (see 3.13 for details). Note 3: other interpreters (IO.SYS and DEBUG.EXE) ignore percent sign and don't replace variables and dummy parameters with their values. . 2.03-04 Double quote sign ( " )

Double quote ( " ) disables interpreter's function of parsing the command line until the next double quote is met in the same line. Thus any group of words between opening and closing double quotes (possibly including separation symbols, redirections, etc) will be interpreted as one item. Enclosing double quotes themselves are considered belonging to the enclosed item. For example, execution of a line C:\>Batch.bat 1 " 2 3 " 4 "" creates a new set of dummy parameters, in which the value of the first parameter is single digit 1, the value of the second is a string " 2 3 ", the value of the third parameter is digit 4, and the value of the last fourth parameter is an empty pair of double quotes. This set of dummy parameters will exist until execution of Batch.bat terminates. Enclosing a group of words in double quotes is a way to include this group of words as a whole (together with any symbols inside) in a value of one dummy parameter. This trick is used, in particular, to preserve integrity of long names in DOS. An empty pair of double quotes ( "" ) is regarded as a special void symbol, enabling to preserve parsing sequence unchanged. Most internal commands in MS-DOS7 (except ECHO, IF and SET) ignore empty pair of double quotes as a separate symbol, but accept the results of parsing affected by double quotes. For example, command C:\>cd "" is executed just as though there were no following symbols at all. When a parameter is enclosed in double quotes, command is executed as though there were no double quotes: C:\>cd "C:\dos"

30

Chapter 2: Command line


Existence of the closing double quote is not checked during parsing of command line, except parsing parameters for FIND (6.14) and FOR (3.13) commands. Both FIND and FOR commands perform parsing in a slightly different way: any group of words enclosed in double quotes is still regarded as one item, but double quotes are not considered belonging to this item. Therefore empty paired double quotes ( "" ) may be used in FIND command for counting total number of lines in textual files. For the same reason the FOR command enables to get rid of enclosing double quotes, when these are no more needed.

2.03-05

Square brackets

Square brackets [ ] are used as a special sign in files, which are to be executed by DEBUG.EXE and by IO.SYS. Data in square brackets are interpreted by DEBUG.EXE as references to operands (see introduction article to chapter 7 for details). In configuration files MSDOS.SYS and CONFIG.SYS, which are to be executed by the IO.SYS loader, the words enclosed in square brackets are interpreted otherwise: as headers, marking beginning of a separate configuration block and at the same time as signs, enclosing name of this configuration block. There are two reserved words, which denote special configuration blocks in CONFIG.SYS file: [menu] and [common]. The [menu] block represents multiconfiguration menu; if it exists, it must be placed the first in CONFIG.SYS file. The menu block is eminent because of a special subset of allowed commands: the MENUCOLOR (4.19), MENUDEFAULT (4.20), MENUITEM (4.21) and SUBMENU (4.29) commands may be used only in blocks, announced as menu or submenu. All other configuration commands, described in chapter 4, except the NUMLOCK command (4.23), can't be used in menu and in submenu blocks. Commands to be executed in all configurations are grouped in one or more blocks with the same name [common]. Outside block headers the names of configuration blocks are referenced without square brackets (4.14). Examples of configuration file CONFIG.SYS with blocks [menu], [common] and some others are shown in 9.04-01 and in 9.09-01.

2.04
2.04-01

Syntactic marks with command mission


Colon

Interpretation of a colon ( : ) depends on its place in command line. Being used as the first character in a line (in batch files only), colon ( : ) forces to interpret the nearest following word as a label, marking a target address point for a jump. There may be more than one word in this line, but all the rest words and symbols will be ignored. Double colon

31

Chapter 2: Command line


( :: ) at the beginning of a line in a batch file is sometimes used in order to disable all operations, specified in this line, including redirection operations (2.04-02 2.04-05). A colon ( : ) in the second place in command line forces to interpret the preceding letter as a letter-name of a disk. If the following part of command line is empty, or is reduced to a single backslash, or is enclosed in backslashes, then the whole line is interpreted not as a path, but as a command to change current disk (make specified disk the default one). For example, in order to make disk A: the current default disk you may type either A: or A:\ or A:\WINDOWS\ and then press the ENTER key. A change of the current disk doesn't alter the default directory on this disk. If the current directory on the target disk is, for example, A:\DOS, it will preserve its status after default disk change in each of the examples above. In such commands any path, enclosed in backslashes, is not checked and even may not exist. In fact any full address, appended with a backslash, will fit as current disk change command. 2.04-02 Left Arrow

Left Arrow ( < ) denotes an operation of input redirection, prepared by COMMAND.COM interpreter for execution of the program, specified in command line to the left of Left Arrow sign. By default the standard input channel (STDIN) is linked with console (CON) and accepts input from keyboard. In fact Left Arrow is a command to link STDIN (handle 0000h) with the data source, specified to the right of input redirection sign. When the utility, specified to the left of input redirection sign, will ask DOS for data input via the STDIN channel, it will get data from this source. Of course, this works only if the utility asks for input via the STDIN channel. For example, command MORE < C:\DOS\Filename.txt supplies the filter utility MORE.COM (6.19) with data read from specified textual file in C:\DOS directory. If directory specification is omitted, then current directory is implied. In any case the file to be read will not be searched for along the paths, enlisted in the PATH variable. Filemasks instead of the source filename are not allowed, wildcards (2.01-03) are not expanded. Besides files, ports (LPT1, LPT2, COM1, COM2, COM3, COM4) may be used as sources of input data. If default links are disrupted by the CTTY NUL command (3.07), then for performing input from keyboard you have to use input redirection with explicit specification of the console (CON) as the data source (example in 3.07).

32

Chapter 2: Command line


In any case of input redirection you must be sure, that specified source will be ready to provide the required data. Waiting for data input from an empty, idle or defective source most probably will cause hanging. Note 1: redirections are arranged by data substitution in JFT table (note 3 to A.07-1). Redirections, prepared by COMMAND.COM for execution of a program, may be cancelled by the program itself (example in 9.07-02). Note 2: other command interpreters (DEBUG.EXE and IO.SYS) ignore left arrow sign as well as other redirection signs (2.04-02 2.04-05). However, the redirections, prepared by COMMAND.COM, are accepted by DEBUG.EXE (examples in 9.02). 2.04-03 Right Arrow

Right Arrow ( > ) denotes an operation of output redirection, prepared by COMMAND.COM interpreter for execution of the program, specified in command line to the left of the Right Arrow sign. By default the standard output channel (STDOUT, handle 0001h) is directed to the console device (CON) - that is to the display's screen. Output redirection forces to direct STDOUT to another target - the one specified to the right of Right Arrow sign. For example, the DEL /? command (3.09) normally presents on-line help to display, but when it is followed by output redirection sign DEL /? > Filename.txt its output wouldn't reach the screen, it will be written into the specified file. A new file with the specified name (Filename.txt) will be created automatically in order to write there the redirected output. If a synonymous file exists yet, it will be overwritten without prompt, and its former contents will be lost. Besides files, allowable targets for redirection may be ports (LPT1, LPT2, COM1, COM2, COM3, COM4), printer PRN (which is usually equivalent to LPT1), display ( CON ) and special quasi-device NUL, which acts just as a "black hole": any output becomes lost there for ever (example in 3.21). This is often used in order to get rid of unwanted messages. If the default link between the STDOUT channel and the display device is disrupted by the CTTY NUL command (3.07), then sending output to display is still possible, but it needs explicit output redirection to CON device (examples in 9.03-02). Output redirection can intercept only those data, which are sent via DOS's normal STDOUT channel. Data sent via BIOS' interrupts (8.01-17, 8.01-21, 8.01-33), via DOS' INT 29 (8.02-88) and via STDERR channel for error messages (handle 0002h) can't be affected by STDOUT redirection.

33

Chapter 2: Command line


If you combine input and output redirections in one line, then the main executable command must be first followed by input redirection with full source specification. Output redirection should be specified afterwards. Examples of combined redirections are shown in 6.14, 6.25-03 and 9.03-02. All symbols of redirection (2.04-02 - 2.04-05) are assigned higher priority, than common operations, except labels (2.04-01) and double quotes (2.03-04). For example, after string input commands (ECHO, SET) all redirection symbols will not be processed as a member of the string, but rather will cause redirection. Because of the same reason redirection ignores conditions, set by IF command, and the only way to execute redirection conditionally is to bypass its line with conditional "IF ... GOTO" jump (3.15, 3.14). Redirection will be executed even if the main operation in the same line is invalid, disabled or provides no output at all. Empty output redirection after the REM command (3.24) is often used to create a file of zero length. Output of a batch file as a whole may be redirected only via loading a separate module of command interpreter COMMAND.COM with /C parameter (6.04) in order to execute this batch file (examples - in 3.22, 9.01-03). Without launching a new interpreter's module the output of a batch file may be redirected in a line-by-line manner from inside of this batch file, but not as a whole. Output redirection should be used with caution, because together with anticipated output it may affect some warnings or invitations for certain action(s) sent to the user. For example, the DIR /P command stops its output after each screenful and sends a message via STDOUT, reminding that output will be resumed after any keystroke. When such messages and warnings are redirected, the screen remains empty, and PC seems having got hanged. 2.04-04 Double Right Arrow

Double Right Arrow ( >> ), just as single Right Arrow (2.04-03), is also a sign of output redirection, but its action is different, when target file for redirection exists yet. Rather than overwrite the target file anew, redirection with Double Right Arrow appends new data to former contents of the existing target file. All other peculiarities of output redirection with the Right Arrow (2.04-03) are applicable to Double Right Arrow as well. 2.04-05 Vertical bar (or "pipe")

Vertical bar or "pipe" separator ( | ) is a sign of intermediate redirection, i.e. data transfer from one utility (or command) to another. Especially for this purpose COMMAND.COM interpreter creates a temporary file. Utility placed to the left of "pipe" is executed first, and its output via STDOUT channel (via handle 0001) is written into this temporary file. Then control is transferred to the utility (or command) placed to the right of

34

Chapter 2: Command line


"pipe". When this utility issues a request for reception of data via STDIN channel (via handle 0000), these data are taken from the prepared temporary file. When execution of the latter utility terminates, temporary file is automatically deleted. For example, following command sequence enables to avoid query on whether the user really wants to delete all the files in specified directory: ECHO Y | DEL C:\TEMP\*.* First an empty temporary file is created. Then the ECHO command is performed, and its output message (a single letter Y) is written into that temporary file. Then the DEL command is executed. Having found the *.* filemask, it issues a request for the user's permission and begins to wait for a reply from STDIN channel. But since its STDIN channel is redirected, execution will not be suspended: the reply letter Y will be automatically read at once from the prepared temporary file. There may be more than two commands linked by "pipes" in one command line. Examples of such command lines are shown in 3.08 and in 3.28. If command, specified to the right of "pipe" sign, doesn't need the contents of temporary file, then the command to the left of the "pipe" sign is not obliged to send a message into STDOUT channel. Hence the "pipe" sign can potentially act as a separator, enabling to specify several commands in one line. However, such usage of "pipes" can't be recommended: the FOR cycle (3.13 ) can do just the same much faster and without access to a writable disk for creation of temporary file(s). Note 1: the "pipe" separator implies creation of a temporary file either in current directory or in the directory, pointed out by environmental variable TEMP. However, both these attempts may fail when DOS is loaded from a non-writable optical disk or from any write-protected media. In such cases an error message informs that the intermediate redirection can't be performed. Then command specified to the right of "pipe" sign will not be executed too. 2.04-06 The "at" ( @ ) sign

Being used as the first symbol in batch file's command line, the "at" sign ( @ ) is interpreted as a command to prevent display of this line on the screen. Therefore almost each batch file begins with the "at" sign, followed by the ECHO OFF command. Sometimes such action is necessary not only in the first line (see 3.13, 6.25-02, 6.25-03 for examples). Note 1: DOS doesn't restrict usage of the "at" sign in filenames, but wrong interpretation of filenames with the "at" sign in a place of the first letter may lead to harmful consequences.

35

Chapter 3
3.01 3.02 3.03 3.04 3.05 3.06 3.07 3.08 3.09 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17

Internal commands
37 37 38 39 40 40 43 44 44 45 47 48 49 51 52 55 56 3.18 3.19 3.20 3.21 3.22 3.23 3.24 3.25 3.26 3.27 3.28 3.29 3.30 3.31 3.32 3.33 3.34 Lock MD Path Pause Prompt RD REM REN Set Shift Time TrueName Type Unlock VER Verify VOL 57 57 58 58 59 60 61 62 62 63 63 64 64 65 65 66 66

Break Call CD CHCP CLS Copy CTTY Date DEL DIR Echo Exit For GOTO IF LFNFOR LH

Internal commands are those executed by command interpreter itself. Contrary to other utilities, which are to be searched for and read from their media, the interpreter is permanently present in memory, and therefore internal commands are executed much faster. Since internal commands are not to be searched for, the path for internal commands shouldn't be specified. One more common property of all internal commands is that after execution they don't leave errorlevel code. This chapter presents internal commands of Microsoft's proprietary command interpreter COMMAND.COM (file size 93812 bytes, file date 12.06.1996). Localized versions of this interpreter usually are slightly larger and have somewhat later date, but nevertheless execute the same set of internal commands. Among the described internal commands are those intended for batch files only (3.02, 3.14, 3.21, 3.27). The COMMAND.COM interpreter provides a short help for its internal commands. In order to display help text you have to type the command's name, followed by a space and the /? parameter, and then press the ENTER key. But the provided short help is often found too short. This chapter presents a lot of clarifications, which will help you to avoid common mistakes and to make internal commands usage much more effective.

36

Chapter 3: Internal commands 3.01 BREAK disk access intercept control

The BREAK command is similar to synonymous configuration command (see 4.02 for details). They both affect the same binary flag, which controls checks of BREAK and CTRL-C keystrokes during disk access operations. This binary flag doesn't lose its state when current resident module of command interpreter finishes its job, and local environment becomes lost. Contrary to the IO.SYS loader (4.02), the COMMAND.COM interpreter shows current state of the mentioned binary flag in response to the BREAK command entered without parameters.

3.02

CALL batch file execution with return

CALL is a command to execute one batch file (the secondary batch) from another batch file (the primary batch). Batch files are non-formatted textual command files, from which the COMMAND.COM interpreter accepts an extended set of commands. The CALL command is just one of those intended to be entered not from keyboard, but only from lines of batch files. Each line in a batch file may include a name of an internal command, or a name of an external utility, or a name of another batch file as well. When command interpreter encounters a name of external utility, it transfers control to this utility, but takes control back after the utility finishes its job, and proceeds to the next line in the same batch file. However, batch files don't behave like ordinary utilities. Having found a name of a batch file (the secondary batch) in a line of another batch file (the primary batch), the COMMAND.COM interpreter begins execution of the secondary batch and doesn't return to the primary one. In order to enable a return to execution of the primary batch file, the secondary one should be launched with CALL command, for example: CALL C:\DOS\VC4\Help.bat J 96 where: C:\DOS\VC4\ an example of a path to HELP.BAT file. If path is omitted, the file will be searched for inside current directory and then according to all path(s), specified by PATH variable. Help.bat an example of a name for the secondary batch file. J 96 specific parameters to be transferred to HELP.BAT file (other batch files may need other parameters or may not need them at all). In fact the CALL command prevents closure of the primary batch file, keeps stored segment of the primary batch file, its dummy parameters and its file pointer position (as a target to return), lets command interpreter to execute another (secondary) batch file, specified after the CALL command in the same line, and then restores access to requisites of the primary batch file, thus enabling a return back to execution of the next operation in the primary batch file.

37

Chapter 3: Internal commands


Note 1: the secondary batch file inherits not a copy of primary environment, but an access to the same primary environment. The values of variables, which have been assigned during secondary batch file execution, will become accessible after resumption of primary batch file execution. Note 2: execution of batch files with the CALL command is allowed to be nested more than twice. Note 3: the CALL command enables to perform recursive calls, that is a batch file may be called from a line inside the same batch file. But it's the user's responsibility to prevent uncontrolled deepening of recursion nesting level. Note 4: if the secondary batch file is not found in the specified directory or in the current directory and throughout all the paths, defined by the PATH variable (2.02-02), then execution will be transferred to the next line of the primary batch file without any error message. Note 5: redirection signs (2.04-02 - 2.04-05) are not allowed in lines with the CALL command. Note 6: the described CALL command, intended for COMMAND.COM interpreter, shouldn't be mixed up with synonymous assembler command (7.03-08) which is to be interpreted by DEBUG.EXE debugger.

3.03

CD change directory

When disk and path are not specified in command line, then MS-DOS implies presence of the addressed object in default (current) directory of the default (current) disk. Default disk assignment has been described in article 2.04-01. Default directory assignment is performed by CD command. The CD command enables to change current directory on any disk (but not the current disk itself) according to a specified path. For example, command CD C:\DOS will set current directory \DOS, if the current (default) disk is disk C:. CD command may be addressed to a disk, which is not the current one, but then specified path is taken into account as a preset, which will become the current (default) directory later, when the disk, specified in CD command, will be given status of the current disk (2.04-01). The path in CD command may be expressed in any of its allowed forms (2.02-01). The final word in the path must be either a name of target directory or any combination of alias signs (2.02-03, 2.03-02). Such combinations enable to perform transition into the root directory ( CD \ ), into parent directory ( CD .. ), to climb two levels up along the directory structure ( CD ..\.. ) and so on. CD command without path specification, for example CD C:

38

Chapter 3: Internal commands


shows a path to the current directory on the specified disk. When disk is not specified too, then the current disk is implied. Note 1: CHDIR is another valid name for the same CD command. Note 2: the directory, which is assigned current by CD command, can't be deleted with RD command (3.23), even if this directory doesn't belong to the current disk. Note 3: preset paths to current directories for all logical disks are stored in CDS table structure (A.03-3). By default it is filled with paths to root directories.

3.04

CHCP change code page

Codepage is an array of characters and symbols used to display messages on the screen. When the CHCP command is used without following codepage number, it shows the number of the codepage, which is currently active. Codepage changing function is usually disabled, unless 2 or more memory buffers for codepages have been prepared by DISPLAY.SYS driver (5.02-02), unless these buffers are filled yet with different codepages by the MODE.COM CON CP PREP command (6.18-03), and unless NLSFUNC.EXE driver (5.02-03) is loaded beforehand. Common practice is to load only one national codepage, because each national codepage contains not only national character set, but american english character set too. Switching between these character sets doesn't imply codepage change: it is performed inside any single national codepage. Loading several national codepages becomes needed when there is no one codepage, containing character sets for the languages, which you intend to use. For example, if you prepared norwegian codepage 865 and russian codepage 866, then commands CHCP 865 and CHCP 866 will perform switching between these codepages. Note 1: codepages may be changed with MODE.COM CON CP SEL command (6.18-03), which doesn't need to have NLSFUNC.EXE driver loaded. Note 2: the CHCP command can't cope with national codepages, loaded by non-Microsoft's drivers, for example by KEYRUS.COM (5.02-05). Note 3: if you use national version of an important utility or of a TSR shell (for example, Norton Commander with russian notation), then changing of the codepage will make this national notation totally non-readable! Only american english notation (characters 32 127, common for all codepages) will not be affected by codepage change.

39

Chapter 3: Internal commands 3.05 CLS clear screen

The CLS command erases all contents of the current screen page in video card memory and also sets colors to default values, thus providing for white text display on a black background.

3.06

COPY make copy of a file

The COPY command is used to copy one file or several files at once. It also enables to concatenate files and to combine copying with renaming. Here is an example of copying one file into another location: COPY /A C:\DOS\MS7\Trial.txt A:\DOS /V /Y where: /A parameter, indicating that the specified source file must be copied no further than the first end-of-file mark (1Ah). For copying only one file into a target file, the opposite /B parameter is taken instead by default. It forces to copy a file as a whole, ignoring end-of-file byte 1Ah, which might play quite different role(s) inside executable files and in binary data files. C:\DOS\MS7\ is an example of a path to the source file. For allowable alternative forms of path specifications see 2.02-01 - 2.02-03. If path to the source file is not specified, this source will be searched for within the current directory only (paths inside the PATH variable are ignored by COPY command). Trial.txt an example of a name for the source file to be copied. If source file name has an extension, it must be specified. Source file may have "A" (Archive) and "R" (Read-only) attributes. Source files with "H" (Hidden) and "S" (System) attributes are not copied. A:\DOS an example of a path to the existing target directory, where the copy should be placed. But if the \DOS directory doesn't exist, DOS will be interpreted as a new name for the copy, and a copy named DOS will be created in the root directory of disk A:. If you don't intend to rename the copy, target path must differ from the source path. If the source is not in the current directory, target path may be omitted, and in this case the current directory will be implied as the target. /V an optional parameter, inducing verification of the copy. It makes copying more slow and is not needed, when the target media is a hard disk. But when the target media is a floppy, the /V parameter may be worth the delay. /Y an optional parameter, giving permission to overwrite any synonymous file in the target directory without prompt. The /Y parameter may be

40

Chapter 3: Internal commands


preset in the COPYCMD environment variable (by command SET COPYCMD= /Y ), and then you will not need to specify it in command line. This preset may be overridden with /Y parameter in command line, when prompt is really needed. When the /A parameter is the last item in command line, its action is quite different: it doesn't prevent from copying the file as a whole, but rather forces the COPY command to append the copy with end-of-file mark (1Ah), if the latter isn't there yet. The first path, specified in the COPY command, is always interpreted as a source path, and the last - as the target path. Specifying more than two paths (or filenames) within one COPY command is regarded as an error, except specifying intermediate source(s), preceded by plus symbol ( + ) for copying with concatenation, for example: COPY /B T1.dat + T2.dat /A + Remark.txt C:\DOS where: copying mode parameter, which precedes the first source name, retains its effect for all following source names until an opposite parameter specification is encountered (/A in this example). The latter spreads its effect for all remaining source names, if there are any. Since concatenation is applied mainly to non-executable files, the /A parameter is taken as default for copying with concatenation. T1.dat, T2.dat, Remark.txt these are three source files for copying with concatenation. Since the paths to the source files are omitted, all these files are implied to be present in the current directory. The following source file names, except the first, must be preceded by plus ( + ) sign of concatenation. C:\DOS is an example of a path to the target directory. When the target directory exists, the result of concatenation will be placed there, and it will inherit the name of the first source (T1.DAT). But if the C:\DOS directory doesn't exist, then the last name DOS will be interpreted as a new name for the combined file, and the result of concatenation named DOS will be written into the root directory of disk C:. A filemask instead of the source filename is allowed, but such specifications should be used with great caution. Let's consider an example: COPY /B T*.dat C:\DOS\Concat.dat The COPY command checks the last word in the target path (to the right of the last backslash) on whether it is a name of an existing subdirectory or not. If subdirectory CONCAT.DAT doesn't exist, all copies of files, conforming to the given filemask, will be concatenated into a new file, which will be created in the C:\DOS directory and will be given name Concat.dat. But if a subdirectory with CONCAT.DAT name exists yet, all files, conforming to the filemask, would not be concatenated, but rather would be copied /B

41

Chapter 3: Internal commands


one-by-one separately into this subdirectory. The latter example shows that the COPY command gives you an opportunity to obtain quite different results with just the same command line. This is why you must know exactly, whether the last name you specify does or doesn't coincide with the name of an existing subdirectory. For copying with concatenation the same file may be specified as a target and as the first source, and this file will be appended with contents of the following source file(s). Specifying a non-first source as the target is not allowed (contents of this source will be lost). When new name for the copy can't be misinterpreted, then you may specify the same path to the source and for the target or even omit both paths at all (current directory will be implied). Copying of one file into itself is qualified as an error. Nevertheless the form of copying with concatenation allows to specify the same paths for a non-renamed copy and for the source. At the same time the name of the second file for concatenation may be omitted, for example: COPY /B \DOS\File.ext +,,\DOS This form of pseudocopying doesn't change file's contents, but is used in order to assign current date to the file or in order to delete the file if it is empty (see notes 1 and 2 below). The reserved word CON (= console) in place of source in COPY command causes the command interpreter not to parse the following input lines as command lines, but to accept the following input as text: COPY CON C:\DOS\Remarks.txt This command enables to write text typed from keyboard into Remarks.txt file, created in C:\DOS directory, until F6-ENTER key combination is pressed to return to command line input (see 1.04 for more details). Reserved words PRN (printer), LPT1 - LPT4 (parallel port), COM1 - COM4 (serial port) or NUL (virtual "black hole") may be used as targets for copying instead of a file. The command COPY CON PRN turns computer into a typewriter. Of course, the chosen target must be properly configured, and the connected terminal device must be able to respond to DOS's request. When the target is a device, then the /A parameter (copy as ASCII text) is taken by default. Contrary to real terminal devices, virtual device NUL is always configured properly. Copying of a real file from physical media (for example, from a floppy) into virtual "black hole" NUL is sometimes used to test whether this file is not empty or whether it is readable. Note 1: empty files (having zero length) are not copied. Note 2: if both target and source(s) are empty, target file is deleted.

42

Chapter 3: Internal commands


Note 3: the result of copying can't be redirected, redirection affects screen messages only. Note 4: attributes of the source file are not copied. Note 5: the copy is always given the "A" attribute.

3.07

CTTY redirection of I/O links

The CTTY command changes settings for all the tree standard I/O channels: STDIN, STDOUT and STDERR. Initial default I/O settings are equivalent to those set by the CTTY CON command: all channels are linked with the CON device (console), that is with the keyboard for input and with display for output. Instead of the console (CON) the CTTY command may accept one of following ports: COM1 (AUX), COM2, COM3, COM4, LPT1 (PRN), LPT2 and also virtual device NUL (for output into "nowhere"). CTTY is an archaic command. Its name (CTTY = Change TeleTYpewriter) reminds about the times when there were no displays, and the I/O consoles resembled old-fashioned teletypes. Nowadays there are 2 reasons to use CTTY in batch files. The first is to prevent accidental interruption of execution; the second is to prevent indication of undesirable error messages, sent via DOS's STDERR channel, which can't be redirected otherwise. In both cases the problem is solved by redirection into nowhere, represented by virtual NUL device: CTTY NUL precedes the group of commands to be protected, and later CTTY CON restores normal communication with keyboard and display. Inside the protected group of commands (between CTTY NUL and CTTY CON) both internal and interactive interruptions of execution are not allowed, because otherwise no message will be displayed, no input will be accepted, and PC may seem to get hanged. Reboot via CTRL-ALT-DELETE usually remains accessible, though. CTTY command affects only implicit I/O settings, but it doesn't affect redirections, which are specified in command lines explicitly (2.04-02 - 2.04-05). For example, let's consider the following piece of a batch file: @ctty nul copy /B Trial.dat Suit.dat echo Press any key to exit > con pause < con ctty con Here a message from the COPY command will not reach the screen, even if it will be an error message. But the message "Press any key to exit" will be shown, because it is directed to the CON device explicitly. The next PAUSE command will work properly too, because its input is explicitly linked with keyboard. This form of CTTY usage needs some caution, but opens attractive opportunities to affect interaction with the user. An example of a batch file with this form of CTTY usage is shown in article 9.03-02.

43

Chapter 3: Internal commands


Note 1: having been banned by CTTY NUL command, the STDERR (error) messages can't be redirected explicitly and are lost.

3.08

DATE date display and reset

In order to set a new date one has to specify this new date after the name of the DATE command in command line, for example: DATE 11.07.2002 When date is not specified, the current date will be shown, and then you will be offered to input a new date via keyboard (pay attention to note 2 below). If you don't want to change the date, just respond to the offer by pressing the ENTER key. Letters and other textual files are often appended with a line with data signature. For this purpose the DATE command should be used, for example, in the following way: ECHO= | DATE | Find.exe "Current" >> Anyfile.txt Here the first redirection ( ECHO= | DATE ) automatically responds to the displayed offer and enables non-stop action, the second redirection ( DATE | Find.exe ) excludes undesirable output lines, and the third redirection ( >> Anyfile.txt ) appends date signature to the specified file. Of course, all conditions for performing redirections (2.04-05) and for finding files (Find.exe and the one to be appended) should be met. Note 1: date and month data order is country-specific and should be set by COUNTRY command (4.05). Note 2: the offer for date change is supplemented with a prompt for a two-digit year data, but it is a bug: MS-DOS7 demands 4-digit year data.

3.09

DEL file(s) deletion

The DEL (DELete) command doesn't physically erase files, but rather disables their entries in directory specification. The clusters, occupied by a file with invalid entry, are considered free and may be overwritten during following operations. But until these clusters are not overwritten, the deleted file may be restored, for example, by the UNDELETE.EXE utility from Norton Utilities release. Here is an example of a command line with the DEL command: DEL D:\TEMP\Filename.ext /P where:

44

Chapter 3: Internal commands


D:\TEMP\ an example of disk and path specification for the directory, containing the file(s) to be deleted. If path is omitted, then current directory is implied. Filename.ext a name example of a file to be deleted; /P optional parameter, causing a prompt for confirmation before deletion of each file. When a filemask (2.01-03) is specified instead of a filename, then all files conforming to this filemask will be deleted. But an attempt to delete all files in a directory by means of filemask *.* causes a stop and a query to the user on whether all files really should be deleted. Execution will be stopped even if the /P parameter is not specified. The user has to respond to the query with Y (yes) or N (no) keystroke. In batch files a non-stop operation is often desirable, without any prompts and queries. This may be achieved, for example, by execution of the DEL command within a FOR cycle: FOR %%Z in (*.*) do DEL %%Z This form of cycle always displays a list of deleted files (even despite redirection to NUL ). You may avoid undesirable messages by implementing the DEL command in another way: ECHO Y | IF EXIST D:\TEMP\*.* DEL D:\TEMP\*.* > NUL In the example above the ECHO Y command provides an automatic response to the query, and the only reason for IF EXIST condition is to avoid the "File not found" error message, when the specified directory (D:\TEMP\) initially is empty. Note 1: ERASE is another valid name for the same DEL command. Note 2: files with attributes R (read-only), H (hidden), S (system) and directories can't be deleted with the DEL command. To delete directories the RD command (3.23) should be used instead. Note 3: the DEL . command (appended with a dot) is equivalent to DEL *.*. Note 4: the DEL \ command (appended with a backslash) deletes in the root directory of the current disk all the files, which are not protected by attributes.

3.10

DIR display of directory contents

In MS-DOS the DIR ( DIRectory ) command is the main instrument of exploring the directories' contents. Here is an example of a command line with the DIR command: DIR C:\DOS /P /A:HS /O:GN /S /L /V where: C:\DOS an example of a path to the directory to explore. If not specified, current directory is implied.

45

Chapter 3: Internal commands


/P /A:HS optional parameter causing a stop after each screenful of output data until any key is pressed by the user. a parameter specifying permission to show the items with particular attributes: H (hidden), S (system), A (new or changed files, not saved in an archive yet), R (read-only), D (directories). Prefix "" may be used to reverse the choice: H (except hidden), D (except directories), and so on. Parameter /A without following attributes forces to show all the items in the directory. When parameter /A is omitted, hidden and system files are not displayed. specification of the sorting order for the displayed items: G directories first, N by name (the default), S by size (smallest first), E by extension, D by date and time (earliest first), A by last access date (earliest first). Prefix "" may be used to reverse the order: N by name with inverse alphabetic order, S by size with largest the first, and so on. an optional parameter, forcing to show contents of subdirectories too. an optional parameter, forcing conversion of the shown filenames to lower case, otherwise these names will be shown just as they were originally specified. an optional parameter, causing display of supplementary data: attributes, time of the last access, allocated disk space, total disk space and its usage. Other parameters, having preference over /V, are: /W show item names in 5 columns, /B show item names in one column, without disk summary; no time loss for preparing summary makes the DIR /B command much more fast.

/O:GN

/S /L /V

The DIR command can be used to show data about a particular file or about all files conforming to a given filemask: DIR *.txt /P /S /B Absence of path specification in combination with /S parameter in the latter example means that the DIR command in fact will perform a search for files with *.txt suffix in the current directory and in all its subdirectories. If current directory is the root, the search will proceed throughout the current disk. If you are interested in finding a forgotten file only, the /B parameter will make the result more concise and easy to apprehend. Parameters for the DIR command may be preset in the DIRCMD environmental variable (for example, with command SET DIRCMD= /P /S /B ), and then you will get the desirable action of DIR command by default. If needed, you may later override any preset parameter by prefixing a hyphen "" to it in command line (for example, /P ). When DIR command is executed with /A parameter, then the *.* filemask (all files) doesn't exclude directories. If you need to display files only, you ought to provide /A: D

46

Chapter 3: Internal commands


parameter instead. This feature enables to explore whether a directory (or a disk) is empty or not. Consider, for example, the following lines from a batch file: @echo off set DIRCMD=/a /b dir *.* > C:\Temp\Found.lst copy C:\Temp\Found.lst NUL | Find.exe "0 file" > nul if errorlevel 1 echo Current directory is NOT empty if not errorlevel 1 echo Current directory is empty The second line specifies parameters so that DIR command will display nothing, if the directory under test is empty. In third line the output of DIR command is redirected into file FOUND.LST. COPY command in the fourth line wouldn't copy an empty file and in this case issues a message "0 files copied". Having caught this message via redirection, the FIND.EXE utility sets errorlevel to zero. The rest two lines are used to sense errorlevel and to display appropriate conditional response. When the DIR command is executed without /W or /B parameters, it may display filenames in two different ways, depending on operating system environment. Inside DOS window of WINDOWS operating system filenames are displayed "as they are", but in MS-DOS7 environment names of files and their suffixes are displayed separately without a dot between them. This feature may be used as a simple test to determine current operating environment. Note 1: the DIR \ command shows all files in the root directory. Note 2: during the DIR command display scrolling of output lines on the screen may be stopped by pressing CTRLS or BREAK keys; then after any other keystroke scrolling will be resumed.

3.11

ECHO string output via STDOUT

The words, specified in the same command line after the name of ECHO command are sent as a message into the STDOUT channel; unless redirected, its default terminal point is the CON (console) device, displaying the message on the screen. Examples of string output with the ECHO command are shown, in particular, in previous article 3.10. The message to display may be up to 123 characters long. Actual message length is limited by the line itself or by the first encountered redirection symbol (2.04-02 2.04-05). Message string may include ASCII service marks, shown in appendix A.02-8. But message string must not be empty or begin with words ON or OFF. These and several other exceptions are used to perform special functions: ECHO ON switches ON the ECHO flag, enabling to display batch file lines as they are executed (this is the default status).

47

Chapter 3: Internal commands


ECHO OFF switches the ECHO flag OFF (no lines display). Outside batch files this causes disappearance of command prompt. ECHO (without following message) shows current status of ECHO flag. ECHO= (appended with equality sign) sends bytes 0Dh 0Ah via STDOUT channel, just as if the ENTER key were pressed (example in article 3.08). On the screen or in a file this causes insertion of an empty line. ECHO+ sends bytes 0Dh 0Ah via STDOUT, but also sends words specified after plus sign, if there are any, including words ON and OFF. The ECHO command acts similarly, when it is appended with slash or dot ECHO flag is a local flag, maintaining its state until batch files share common environment, but this state is not inherited and is reset to default each time the command interpreter creates a derived (child) environment. Command lines displayed in the default ECHO ON state are not the same as original command lines in batch files: in displayed lines all aliases are replaced with their values. This is helpful for debugging. But it is not needed, when file has proved to have no errors. Therefore almost each completed batch file starts with @ECHO OFF command. The "@" character, preceding the ECHO command, prevents display of this command itself.

3.12

EXIT closure of current interpreter session

Command interpreter COMMAND.COM (6.04) is a resident program, which arranges environment for execution of other programs. On the other hand, command interpreter itself may be launched just as an ordinary program in order to arrange a separate (local) environment, if it is required. In such cases several resident modules of command interpreter may coexist in memory simultaneously, but only one of them may be active the one which is loaded the last. The EXIT command closes current session of the active resident module, releases the memory occupied by the module, and transfers control to the parent program (which has launched the mentioned resident module). Just as current interpreter session is closed, its local environment with all values and variables becomes lost. At the same time the former environment of the parent program becomes accessible again, and execution of this program is automatically resumed. The very first resident module of command interpreter is launched by the IO.SYS loader with the SHELL command (4.26) in CONFIG.SYS file (9.01-01). This first resident module can't transfer control to its "parent", since the IO.SYS loader is not resident and has finished its job yet. If the first resident module of command interpreter were able to execute the EXIT command, then computer were get hanged. To prevent such outcome the COMMAND.COM interpreter must be launched for the first time with the /P parameter (6.04), which disables EXIT command.

48

Chapter 3: Internal commands 3.13 FOR cycle operator

The FOR cycle operator arranges cyclic execution of other command(s). Assume, for example, that we need to display three short files: First.txt, Second.txt and Third.txt. Instead of sending these files to display with separate commands, the FOR operator enables to do the same in one line: FOR %Z IN (First Second Third) DO TYPE %Z.txt where: %Z an example of a name for cycle variable, which is sequentially set equal to each of the items specified in parenthesis. Cycle variable name shouldn't commence with a digit. Usually it is a one-letter name, preceded by a percent symbol ( % ), when the cycle is executed from command line, or by double percent symbol ( %% ), when the cycle is executed from a batch file. a required reserved word, introducing the following list of variable's values, specified inside parenthesis. a required reserved word, introducing the following name of the command, which is to be executed in the cycle as many times as many values are specified for the cycle variable. In each iteration a new value is substituted for the name of cycle variable.

IN DO

Item(s) in parenthesis may be any word(s), including environmental variable substitutions (such as %TEMP%) and dummy parameter substitutions (2.03-03). Items in parenthesis may be separated by spaces, or by semicolons ( ; ), or by commas ( , ). Note, that paths in PATH variable value are separated by semicolons, hence the PATH's value will be disintegrated by the FOR cycle into a group of separate paths. This operation is often used in order to determine accessibility of a given file or in order to provide explicit path specification for it. The following piece of a batch file shows a typical path determination example: @echo off set P= FOR %%Y IN (. %PATH%) DO if exist %%Y\Fc.exe set P=%%Y\Fc.exe if %P%"==" echo Requested file hasn't been found! if not %P%"==" echo Path to the requested file is %P% Here in the second line an auxiliary variable P is assigned an empty value, and in the third line - the path to the specified file, if the latter happens to be found. Note, that cycle variable name ( %%Y ) is preceded by double percent symbol, as it must be in batch files. The last two lines check presence of auxiliary variable's value and issue a corresponding message according to the result.

49

Chapter 3: Internal commands


Item(s) in parenthesis may include wildcards (2.01-03), but items with wildcards become interpreted as filenames, which should be searched for in the current directory or according to the preceding path, if it is specified. Automatic search along all the paths in the PATH variable is not implied. Each of several items in parenthesis may include wildcards, for example: FOR %%X IN (A:\*.txt A:\*.doc) DO COPY /B %%X C:\DOS Sometimes it is desirable to display separately each operation performed within FOR cycle, but not the cycle itself. This opportunity may be illustrated by the following modification of the preceding example: ECHO ON @FOR %%X IN (A:\*.txt A:\*.doc) DO COPY /B %%X C:\DOS @ECHO OFF If the file, specified in parenthesis with wildcards, is not found, then corresponding operation is skipped without any error message. This is why the FOR cycle sometimes is used as a means to get rid of undesirable error messages (see 3.09 for an example). One more "side effect" of the FOR cycle is that it enables to parse a multi-word value of an environmental variable and to get rid of extra spaces, which may precede or follow separate words within this value. Inside parenthesis a string, including separation symbols, may be regarded as one item, if it is enclosed in double quotes (absence of the closing quote is qualified as an error). Double quotes themselves are not regarded as belonging to the item. This enables to specify several different commands in one line, for example: FOR %%Z IN ("set E=%W%" "echo E is set" "goto L23") DO %%Z There are sequences of operations, which can't be performed in separate lines, but can be performed within the FOR cycle. Examples of such sequences are shown in 46-th line of batch file in article 9.03-02, and also in the 6-th line of batch file in article 9.01-03. Inside parenthesis the commands, enclosed in double quotes, may include substitutions of variable's values (as %W%), conditional commands ( IF ), jump commands (GOTO) and redirections (2.04-02 - 2.04-05). When a jump to a label is performed from within the FOR cycle, the next operations (placed to the right, if such exist) will be skipped. Redirections inside the FOR cycle spread their action on all following commands. For example, in a cycle For %%Z in ("echo 1-st line >> Q.txt" "echo 2-nd line") do %%Z the words "2-nd line" will not be shown on the screen, but rather will be appended to the Q.txt file. Redirection for the following operation(s) can be changed, but it must be specified explicitly.

50

Chapter 3: Internal commands


The ability of FOR cycle to take away enclosing double quotes from its arguments is essential not only for execution of commands, but also for displaying messages, protected from parsing by double quotes. Nested FOR cycles are not allowed, but an internal FOR cycle may be executed by a separate resident module of command interpreter (COMMAND.COM), which itself is launched within an external FOR cycle, specified in the same command line. If inside a batch file the FOR cycle is used to execute another (secondary) batch file, this secondary batch file may contain its own internal FOR cycles. Note 1: the name of the cycle variable must be chosen so as to prevent interference with any of currently used other variables. Note 2: inside parenthesis the forward slash ( / ) is regarded as separator, but any single item preceded by the forward slash will be appended to this slash and converted to the upper case (in earlier DOS versions slash acts otherwise). Note 3: attempts to redirect all messages from FOR cycle affect only the first operation within this cycle. If the following operations have no explicit redirections, they will be subjected to default settings. Note 4: when interpreter COMMAND.COM is explicitly launched from command line in order to execute a FOR cycle, the cycle variable must be preceded by double percent signs, just as in batch files.

3.14

GOTO jump to a label

The GOTO command performs a jump within batch file to a label, which must be specified in any line of the same batch file. A line with label begins with a colon ( : ), and after the colon an arbitrary label's name follows. The same name must be specified after GOTO command. When label's name is long, its first 8 characters only are taken into account. Synonymous labels in one batch file are not allowed. If, for example, there is a label :L36 in some line of a batch file, then a jump to this label is performed by command GOTO L36 The GOTO command may be preceded in the same line by conditional operator IF (3.15). A lot of jump examples, both conditional and unconditional, can be found in articles 9.03-02, 9.09-02. Note 1: label name after the GOTO command can be obtained by substitution for a variable's name (%VAR%, for example). Note 2: a value of dummy parameter (%1, %2..) cannot be used after the GOTO command as name of a label, but it may constitute a part of this name after any preceding letter(s). Note 3: the GOTO command doesn't affect errorlevel, thus giving an opportunity to continue errorlevel checks after the jump.

51

Chapter 3: Internal commands 3.15 IF condition operator

Condition operator enables to perform three types of condition checks: existence check, equality check and errorlevel check. Command line with conditional execution of any operation must commence with conditional operator IF, followed by condition type definition, condition specification and full specification of the command, which should be executed if the condition is met. Several condition operators with separate condition definitions and specifications may be written sequentially in one line, and then logical operation AND is applied implicitly to results of separate condition checks. Examples of combining several condition checks in one line are shown in articles 3.15-03, 9.03-01, 9.09-02. Peculiar composition of command line for each type of condition checks is described below in detail. 3.15-01 Existence condition check

Existence condition check, performed by IF EXIST command, can be applied to files, directories and logical devices. Inversion of existence condition absence condition check is performed by IF NOT EXIST command. Here are two examples of existence check usage: IF EXIST C:\DOS\Format.com C:\DOS\Format.com A: /S IF NOT EXIST C:\DOS\Format.com ECHO Format.com isn't found! where: EXIST a reserved word, defining type of check and forcing to interpret the following element as a name or a mask (may be with path) of the object to be searched for. C:\DOS\Format.com an example of a filename to be searched for; preceded by a path. This filename will be searched for in the specified directory only. When path is omitted, then current directory is implied. C:\DOS\Format.com A: /S an example of a utility to be launched if the preceding condition is met ( if the check returns TRUE). Note, that utility name should be followed by all necessary parameters. When path is not specified, the utility will be searched for in current directory and then along all the paths, stored in PATH variables value. NOT a reserved word, meaning a logical inversion of the result (TRUE or FALSE), returned by a check of any condition type. ECHO Format.com isn't found! another example of a command to be executed depending on preceding condition (when the utility is NOT found).

52

Chapter 3: Internal commands


Given examples enable to execute a specified utility (FORMAT.COM), when it is found in its proper place, or to have an intelligible message displayed, when this utility isn't found. Names of logical devices are reserved words (2.01-01), assigned by DOS's core or by drivers during loading procedure. By existence check, applied to a logical device name, one can clear up whether a particular driver is loaded. Full list of logical devices in your computer is shown by the MEM.EXE utility being launched with /D parameter (6.17). For example, the EMM386.EXE (5.04-02) driver reserves logical device name EMMXXXX0. Hence the loading check for this driver can be done with the following line: IF NOT EXIST EMMXXXX0 ECHO The EMM driver isn't loaded! When you use a filemask with wildcards instead of utility name to be searched for, it will be referred to conforming files only, but not to directories. Existence condition with filemask *.* is true, when there is at least one file (or more, example in 3.09). In order to check existence of a directory you should append the directory name with a name of virtual file NUL: IF EXIST C:\DOS\NUL ECHO The C:\DOS directory exists! However, the shown check for existence of a directory may fail on CD-ROMs because of peculiarity of their file system (ISO 9660). It is often important to provide non-stop execution of batch files. The existence check provides non-stop execution on accessible media only: the file or directory may not exist, but disk must exist (must be inserted) and must be formatted with a file system accessible for MS-DOS7 (FAT12, FAT16, FAT32) or accessible by means of installed drivers. When it is not known whether the media is accessible, a non-stop execution of the existence check still may be performed, but it needs special measures to prevent critical error handler calls (8.02-84) and to avoid appearance of undesirable messages (example in 9.03-02). 3.15-02 Equality condition check

Equality condition check is applied to two words, separated by double equality symbol ( = = ). Since there is no sense in comparing a-priori known words, equality condition implies using aliases, which may be dummy parameter(s) or variable's value(s) (2.03-03). Wildcard symbols ( ? and * ) in words to compare are allowed, but these are interpreted as ordinary symbols and are not expanded as wildcards. Contrary to ordinary DOS' practice, upper and lower case letters in words to compare are regarded as NOT equal. Here are two examples of equality check usage in batch files: IF %VAR%==%2 GOTO L23 IF NOT %VAR%==%2 GOTO HELP

53

Chapter 3: Internal commands


where: %VAR% an alias to be replaced with value of environmental variable VAR; %2 an alias (dummy parameter) to be replaced with the second parameter's value of the batch file; GOTO L23 a command to be executed if the %VAR%= =%2 condition is met; NOT a reserved word, meaning a logical inversion of the result (TRUE or FALSE), returned by condition check; GOTO HELP a command to be executed if the %VAR%= =%2 condition is NOT met. Of course, any one of the words to compare may be specified directly, without aliases. Each of the words to compare may combine one or more aliases with directly specified part(s). But words to compare are not allowed to be empty: this is regarded as syntax error. Since any batch file may be executed without parameters, it must be prepared to the case when its dummy parameter ( %2 in the example above or any other) becomes empty. The simplest way to solve the problem is to append any certain symbol (for example, a dot) to both left and right parts of the equation: IF %VAR%.==%2. GOTO L23 IF NOT %VAR%.==%2. GOTO HELP These equality checks do the same as in the previous example, but are immune against the empty value of the aliases. The same principle is used to compose a check on whether the value of a variable (or of a dummy parameter as well) is empty: IF .==%CASH%. ECHO The CASH variable has an empty value Special care should be taken when the value of a variable may include spaces. The word to the right of the double equality symbol doesn't allow space(s) in its value. If the value of the variable CASH (in the example above) includes spaces, it will be interpreted as syntax error. But the word to the left of double equality symbol is allowed to have spaces inside. When this word consists of several items, separated by spaces, only the first (leftmost) item will be taken into account. This is illustrated by the following three examples (all three are valid): IF NOT A: B: C:.==. ECHO Compared items are not equal IF .A: B: C:==.A: ECHO Compared items (.A: and .A:) are equal IF . B: C:==. ECHO Compared items (dots) are equal too In all these three examples presence of the B: and C: items is ignored. 3.15-03 Errorlevel condition check

When execution of any utility in DOS is about to terminate, it may leave errorlevel code, which is in fact a message to the following algorithms. Errorlevel informs whether the terminated execution has been successful or not, and if not, then what kind of obstacle

54

Chapter 3: Internal commands


has been encountered. Errorlevel is a 8-bit binary code in DOS's swappable data area (offset 14h in A.01-03), but it is presented as decimal number from 0 to 255 (without sign). Errorlevel 0 means successful termination, other errorlevel values usually mean different kinds of errors, interpreted specifically for each utility. Errorlevel condition is identified by presence of the word ERRORLEVEL. It gives an opportunity to check whether the errorlevel code is equal or greater than a specified decimal number, for example: IF ERRORLEVEL 1 ECHO Execution has failed IF NOT ERRORLEVEL 1 ECHO Execution has terminated successfully The check in the first line of the example above returns TRUE for all errorlevel values from 1 to 255, that is for all possible unsuccessful outcomes. The check in the second line includes reserved word NOT and this is why acts as logical inversion, returning TRUE for errorlevels lower than 1, that is for a single value 0, which means successful termination. When you need to execute a separate procedure for a single type of erroneous outcome, you may concatenate errorlevel checks. Suppose, for example, that in the case of errorlevel 15 you need to perform a jump to label ERROR15. This may be achieved by the following command line: IF NOT ERRORLEVEL 16 IF ERRORLEVEL 15 GOTO ERROR15 The first check in the line above returns TRUE for all errorlevels from 0 to 15, and the second - for all errorlevels from 15 to 255. The result is that errorlevel 15 becomes the single errorlevel value, which enables to execute the following GOTO command. Note 1: non-zero errorlevel code is used by some utilities to indicate different circumstances of normal (not erroneous) outcome. Note 2: all internal commands (3.01 - 3.34) don't return and don't change errorlevel code. Note 3: mixed successive concatenation of several existence checks, equality checks, and errorlevel checks in one line is allowed in the same way as that shown above for two errorlevel checks.

3.16

LFNFOR long filenames display mode

LFNFOR is an undocumented local switch, which may be set ON (LFNFOR ON) or OFF (LFNFOR OFF). Being used without parameters, LFNFOR command shows the state of this switch. It's default state is OFF. Under "bare" MS-DOS7 the state of LFNFOR is ignored, but inside DOS box under Windows OS switching LFNFOR ON enables non-truncated treatment of long file names by the FOR command (3.13), for example, by FOR %%Z in (*.*) do echo %%Z

55

Chapter 3: Internal commands


When LFNFOR is switched OFF, the FOR command truncates long file names to 8 characters, just as it always does in MS-DOS7.

3.17

LH load beyond conventional memory

The LH command (LH = Load High) loads drivers and TSR utilities beyond the 640 kb boundary of conventional memory in computers having the 80386 or higher processor. Access beyond the 640 kb boundary must be enabled in advance by command DOS=UMB (4.08) in CONFIG.SYS file and by loading memory managers: the HIMEM.SYS driver (5.04-01) and then either EMM386.EXE (5.04-02) or UMBPCI.SYS (5.04-04) driver. In both cases access to the TSR modules, loaded by the LH command, will be performed via the UMB region (640 - 1024 kb) of address space. When there is no more free space in UMB region, the LH command issues no error message and continues to load drivers and TSR utilities into conventional memory below 640 kb. LH acts similar to the INSTALLHIGH command (4.16); the main difference is that INSTALLHIGH command is performed by the IO.SYS loader and can't take part in memory optimization procedure (5.04-03). The LH command is performed by COMMAND.COM interpreter from ordinary command line or (preferably) from a line in AUTOEXEC.BAT file. Here is an example of a line from AUTOEXEC.BAT file, in which the LH command is used to load MSCDEX.EXE driver: LH /L:1,23680 \DOS\DRV\Mscdex.exe /D:CD1 /E /S /V /L:O /M:32 The name of the driver is preceded by a path ( \DOS\DRV\ ), which may take any of its allowed forms (2.02-01). If the path is omitted, the driver will be searched for in the current directory and throughout all the paths, specified in PATH variables value (2.02-02). All items following the driver's name are not identified by LH command, but rather are transferred to the driver as its specific parameters. Between the name of LH command and specification of the software to be loaded there may be an optional /L parameter, which gives an opportunity to point out a particular part of USB memory region, which should be devoted for access to each TSR module (see also 4.07). In the example above this parameter looks as /L:1,23680, where /L:1 means addressing via the first part of UMB region, and the number 23680 is the size of space (in bytes) required for TSR module of MSCDEX.EXE driver. Size specification after the /L parameter is optional, but when the size is specified, the LH command can accept one more parameter /S, for example: LH /L:1,2160 /S \DOS\COM\Escape.com The /S parameter means that allocated UMB block should be truncated to the specified size. This results in the most efficient usage of address space, but doesn't guarantee from a crash, if size specification is not quite correct. It is not recommended to

56

Chapter 3: Internal commands


use the /S parameter apart from memory optimization procedure, performed by memory optimization utility MEMMAKER.EXE (5.04-03). During this procedure the /L and /S parameters together with exact size specification will be automatically inserted in all those lines of AUTOEXEC.BAT file with LH command. Note 1: if access beyond conventional memory is opened by UMBPCI.SYS driver (5.04-04), then LH command loads TSR modules into UMB memory region (640 - 1024 kb). But EMM386.EXE driver (5.04-02) acts otherwise: it adjusts processor's address translation table (TLB) so that access to memory beyond 1088 kb is performed via the same UMB region of address space. This is why in the latter case the same LH command physically loads TSR modules not into the UMB region, but elsewhere beyond 1088 kb.

3.18

LOCK forbid concurrent access

Requests of various programs for disk access are controlled by MS-DOS7 in order to provide proper order of access and effective buffering. Programs, which require direct access to a disk, must coordinate their operations with MS-DOS7 by means of the INT 13\AH=45h interrupt (8.01-58). But some programs don't do that, for example, the program for recovering deleted files UNDELETE.EXE from MS-DOS6.22 release. In order to permit such programs to do their job the COMMAND.COM interpreter in MS-DOS7 provides the LOCK command. It gives exclusive rights to access the requested disk for the program, which will be launched next. Arguments for the LOCK command are one or more letter-names of the disks, which should acquire exclusive treatment. During execution of LOCK command you will be asked for confirmation (Y or N) from keyboard. In order to avoid stops for confirmation in batch files you have to prepare a response in advance, for example ECHO Y | LOCK C: D: The result of the shown command line will be excusive non-interrupted access to disks C: and D: for the program which will be launched next. When this program terminates, the locked state of disk(s) should be turned off by UNLOCK command (3.31). Since direct access operations may be nested, up to 256 lock levels are allowed. Of course, each involved program must be supported by proper sequence of LOCK and UNLOCK commands.

3.19

MD make directory

The MD command enables to create a new directory or subdirectory, for example: MD C:\DOS\ARC where:

57

Chapter 3: Internal commands


C:\DOS\ an example of a path to an existing directory, where the new subdirectory should be created; ARC an example of a unique name for the new subdirectory to be created. Backslash after this name is not allowed. The unique new name is a required argument, but the preceding path is optional. When it is omitted, new (sub)directory will be created in the current directory of the current disk. Note 1: MKDIR is another valid name for the same MD command.

3.20

PATH search path(s) specification

The PATH command defines the default paths for searching programs, which have no prescribed path and are not present in the current directory. The paths, specified by PATH command, constitute the value of synonymous environmental variable PATH. Its value may be defined by SET command (3.26) as well. But there is an important difference: unlike SET command, PATH command automatically converts all the characters in the specified path(s) into upper case (otherwise search procedure may go wrong). The PATH command must be followed by one or more existing paths, separated by semicolon(s), for example: PATH C:\DOS\VC4;C:\DOS\MS7;C:\WINDOWS\COMMAND Ability of PATH command to convert arbitrary word(s) into upper case is sometimes used in order to avoid ambiguities further in course of case-sensitive equality check. Note 1: within a string of path specifications there must be no spaces on both sides of each semicolon separator. Note 2: there must be no semicolon at the end of a string of path specifications. Note 3: the PATH command with no following arguments just displays the defined paths and leaves them unchanged. Note 4: the PATH ; command (followed by one semicolon only) deletes all previously defined paths. Note 5: the name of PATH command may be separated from the following string of path specifications by either a space or by equality sign ( = ) as well.

3.21

PAUSE temporary stop

The PAUSE command, being encountered in a line of a batch file, stops execution of this batch file and displays message "Press any key to continue...". This message is not quite true, because CTRL-C, CTRL-BREAK and ALT-03 keystroke combinations terminate execution, enabling to bypass all the rest lines of batch file (this action doesn't depend on the BREAK status). When PAUSE's message is not desirable, it may be redirected:

58

Chapter 3: Internal commands


PAUSE > NUL PAUSE command may be followed in the same line by a commentary string, just like the REM command. This commentary will not be displayed unless the ECHO flag (3.11) is set ON. When default communication with console is halted by the "CTTY NUL" command (3.07), then PAUSE command must be given explicit input redirection: PAUSE < CON In batch files redirection of the 03h symbol (shown as , see A.02-8) to PAUSE command provides the shortest way to quit execution of the batch file at once, without any pause: ECHO | PAUSE > NUL Symbol 03h may be inserted into command line with ALT-03 keys, the digits should be entered via numerical keypad while the ALT key is kept pressed. But you shouldn't dare to disable such line by a preceding REM command (3.24): the ECHO command only will be disabled, redirected symbol wouldn't be received by PAUSE command, and the computer will get hanged.

3.22

PROMPT prompt specification

Command PROMPT redefines the value of synonymous environmental variable PROMPT, which specifies the form of DOS's command prompt. Usually the PROMPT command is written in a line of AUTOEXEC.BAT file, but it also may be entered from an ordinary command line. The name PROMPT should be followed by the suggested prompt text. In this text pairs of characters, beginning with a dollar symbol ( $ ), are interpreted in a special way and are substituted with other data, which can't be written into prompt text directly. Here is a table of correspondence between character pairs and the substituting data: $Q equality sign ( = ) $$ single dollar symbol ( $ ) $T current time $D current date $P current disks letter-name and path to current directory $V Windows' version number $N current disks letter-name $G right arrow (or greater-than) sign ( > ) $L left arrow (or less-than) sign ( < ) $B vertical bar (or pipe) sign ( | ) $H the 08h code "Backspace" (A.02-8) $_ carriage return (0Dh) and linefeed (0Ah)

59

Chapter 3: Internal commands


$E code 1Bh "Escape" (A.02-8)

The PROMPT command without arguments deletes the variable PROMPT, and then DOS's prompt would present current disks letter-name appended with right arrow sign ( > ), the same prompt as after command PROMPT $N$G. By default MS-DOS7 assigns to the PROMPT variable another value ( PROMPT $P$G ), which corresponds to most common form of command prompt: full path to the current directory appended with right arrow sign. The data, displayed by prompt, can be written into a file and then assigned as a value to an environmental variable. Consider the following example of batch file lines: prompt @echo off$_Set Ret$q$p C:\Command.com /c Ret.bat > Ret.bat Call Ret.bat The first line in the example above sets a complicated form of a prompt, and the second line writes this prompt into a new batch file RET.BAT. Obtained RET.BAT file's contents may look as follows: @echo off Set Ret=D:\BACKUP Note, that prompt parameter "Set Ret$q$p" has been transformed into "Set Ret=D:\BACKUP", where "D:\BACKUP" is an example of current disks lettername followed by actual current path at the moment of batch line execution. If you execute the RET.BAT file with CALL command (3.02), then actual full path will become written into value of environmental variable RET. After that you can delete RET.BAT file and may use the RET variable whenever necessary in order to return to the former disk and directory: %Ret%\ CD %Ret% Another example of PROMPT command usage for obtaining current disks letter-name is shown in article 9.01-03. Current time, date and OS version number can be written into environmental variable(s) in a similar way.

3.23

RD remove directory

The RD command (Remove Directory) enables to delete a directory, if the following conditions are met: the directory to be deleted is empty; the directory exists on a writable disk; the directory is not the root directory of a disk;

60

Chapter 3: Internal commands


the directory is not the current directory on its disk, even if the addressed disk is not the current disk. Here is a RD command usage example: RD D:\TEMP\NOTES where: NOTES is the name of a directory to be deleted; D:\TEMP\ is an example of a path to the directory to be deleted. The path may be specified in any of its allowed forms (2.02-01, 2.02-03). If path is omitted, a subdirectory of the current directory is implied. Note 1: RMDIR is another valid name for the same RD command.

3.24

REM remark line

The REM command (REMark) forces COMMAND.COM interpreter to ignore all the following character(s) in the same command line up to any nearest sign of redirection (2.04-02 - 2.04-05) or up to the end of the line. Main mission of the REM command is to provide an opportunity to insert lines of commentaries in batch files. Commentaries may be up to 123 characters long in one line. The REM command is used for those commentaries, which shouldnt be displayed during normal execution of a batch file, but rather are to be displayed only for tracing while the ECHO flag is kept ON (3.11). The REM command is sometimes used to disable an executable line in a batch file, but it can't disable redirection. Double colon "::" (2.04-01) is more suitable for this purpose. The other mission of REM is an "empty" command, which is accepted as valid and formally is executed, but does nothing (see VCEDIT.EXT in 6.25-03 for an example). Since the REM command sends no output into STDOUT channel, redirection REM > Anyfile.ext is used to create an empty file with specified name. If a synonymous file exists there yet, it will be overwritten and will become empty. Overwriting of a real file with a file of zero length erases address of its first cluster in directory specification. Therefore files, overwritten by a file of zero length, can't be restored by UNDELETE.EXE or by other similar utilities. Note 1: REM command shouldn't be used to disable command lines with intermediate redirection (2.04-05). The REM command disables only the first command in such line, its output is not sent, and command in the rest part of command line never gets the awaited data. Therefore computer may get hanged (example in article 3.21). Note 2: inside "DOS box" of Windows OS empty redirections are not performed, so there the REM command can't be used to create a file of zero length.

61

Chapter 3: Internal commands 3.25 REN rename a file

The REN command (REName) enables to rename one file or several files at once if their names conform to a certain mask. Here is an example of renaming one file with REM command: REN C:\DOS\Notes.txt Notes.old where: C:\DOS\ an example of a path to the file to be renamed; the path may be specified in any of its allowed forms (2.02-01, 2.02-03) or may be omitted. Notes.txt current name of the file to be renamed. Notes.old an example of new name for the same file; the new name must be specified without preceding path, even if the file to be renamed exists anywhere else beyond the current directory. Specifying wildcards within the first (old) name only is allowed, but often leads to an error: attempt to create several synonymous files in one directory. Therefore it is recommended to specify wildcards in the same positions in both old and new filenames, so as to retain unique features of each filename. Characters hidden under wildcards will not be changed. Suppose there is a group of files Part_01.txt Part_12.txt, which should be renamed into Chap_01.txt Chap_12.txt. This operation is performed with one command: REN Part_??.txt Chap_??.txt Note 1: directories and files with H (hidden) attribute can't be renamed by the REN command. Note 2: attributes of the renamed file(s) remain unchanged.

3.26

SET value assignment to a variable

When SET command is specified without parameters, it displays all variables of the current environment together with their values. But if name of the SET command is followed by any word, this word is interpreted as a name of environmental variable, which should be assigned a new value, for example: SET TEMP=D:\Temp where: TEMP is an example of variable's name; D:\Temp is the value to be assigned to the variable TEMP. Equation sign(s) and redirection symbols (2.04-02 2.04-05) inside value specification are forbidden.

62

Chapter 3: Internal commands


Note 1: any space to the right of the equation sign between valid characters, preceding or following valid characters (up to the end line mark) will be included in variable's value. Note 2: if a part to the right of the equation sign is empty, then specified variable will be deleted (will cease to exist). Note 3: the SET command is able to expand environmental space, when it is not enough to accommodate the new value of a variable. Note 4: in batch files the value to the right of the equation sign may include substitutions for other variable's names (for example, %VAR%) and for dummy parameters (2.03-03). All such aliases will be replaced with their values before defining the new variable. Note 5: a synonymous command SET (4.25) in lines of CONFIG.SYS file is interpreted by IO.SYS loader. The latter doesn't perform substitutions and redirections, but thus it gives an opportunity to include corresponding symbols in variable's value(s).

3.27

SHIFT dummy parameters order shift

The SHIFT command shifts by 1 (minus one) the numerical order of dummy parameters (2.03-03) in a batch file, so that former %0 is lost, former %1 becomes %0, former %2 becomes %1, and so on. It's important to notice, that the dummy parameter, which becomes the 9-th, previously was the 10-th and couldn't be accessed. Thus the SHIFT command gives an opportunity to specify more than 9 dummy parameters for a batch file and to access them sequentially, shifting their numeration from one iteration to each next. An example of such numeration shift is presented by a subroutine in lines 29 38 of DISK.BAT file in article 9.03-02. When the shifted address order comes to the end of parameter's sequence, the last dummy parameter becomes empty, and this is a sign to terminate execution of the whole cycle containing the SHIFT command.

3.28

TIME time display and reset

In order to set a new time one has to specify this new time after the name of the TIME command in command line, for example: TIME 11:39:23,24 where the successive numbers mean hours, minutes, seconds and the hundredth parts of a second. Separation symbols within the shown time specification are colons and a comma, but it depends on what national conventions are set by the COUNTRY command (4.05). When time is not specified, the current time will be shown, and then you will be offered to input a new time via keyboard. If you don't want to change time, just respond to the offer by pressing the ENTER key.

63

Chapter 3: Internal commands


In order to append a textual file with a time signature, the TIME command should be used, for example, in the following way: ECHO= | TIME | Find.exe "Current" >> Anyfile.txt Here the first redirection ( ECHO= | TIME ) automatically responds to the displayed offer and enables non-stop action, the second redirection ( TIME | Find.exe ) excludes undesirable output lines and the third redirection ( >> Anyfile.txt ) appends time signature to the specified file. Of course, all conditions for performing redirections (2.04-05) and for finding files (FIND.EXE and the one to be appended) should be met.

3.29

TRUENAME canonical form for path and name

Any specification, following TRUENAME command in the same command line, is interpreted as name of an object (file or directory), which may be preceded by a path. The TRUENAME command doesn't check whether the given specification corresponds to a real file or to a real directory structure, but rather tries to translate it into canonical form, which must commence with disks letter-name and must include full path to the object. If the given specification isn't complete, it may be automatically supplemented with letter-name of the current disk and a path to the current directory. If the given specification contains dot aliases (2.02-03), these will be expanded to full paths which they denote. Besides this, all letters are uppercased, forward slashes are converted to backslashes, asterisks (2.01-03) are converted into appropriate number of question marks, long names are truncated to 8 characters, long suffixes to 3 characters. If the original specification points out a fake path, arranged by utilities ASSIGN.COM, JOIN.EXE or SUBST.EXE, then the TRUENAME command returns the true path. When used without following specification, the TRUENAME command returns full path to the current directory, just as CD command (3.03). Note 1: the TRUENAME command doesn't display error messages. Note 2: the TRUENAME command can't be applied to network paths, unless a LAN driver is installed. Note 3: the action of TRUENAME command is based on INT 21\AH=60h (8.02-72).

3.30

TYPE read a file to STDOUT

The TYPE command reads contents of a specified file and sends it line-by-line into STDOUT channel, which has the CON device (display) as its default terminal point. Sending may be terminated by CTRL-C or CTRL-BREAK keystrokes, or suspended by pressing CTRL S or BREAK keys and then resumed by any other keystroke. Usage example: TYPE C:\DOS\Notes.txt

64

Chapter 3: Internal commands


where: Notes.txt a name example of the file to be displayed; wildcards in a name are not allowed by TYPE command. C:\DOS\ is an example of a path to the file to be displayed; the path may take any of allowed forms (2.02-01, 2.02-03) or be omitted. In the latter case the file is implied to exist in the current directory. Output of the TYPE command may be redirected, for example, to the printer, connected to LPT1 port: TYPE A:\Config.sys > PRN The TYPE command is often used together with the MORE.COM viewer (6.19), which displays long STDOUT messages page-by-page.

3.31

UNLOCK concurrent access permission

After termination of each program, which has been given direct access to a disk with LOCK command (3.18), the original access state should be restored by the UNLOCK command, applied to the same disk, for example: UNLOCK C: In fact the UNLOCK command doesn't permit concurrent access, but rather decreases by 1 the count of nested ban levels, forbidding concurrent access. Thus a proper treatment of nested program calls is provided. But if the original ban level was 1, then UNLOCK command will reactivate a queue of requests for access to the disk. This is important in multitasking operating environment, for example, in "DOS box" under Windows95/98 OS. If a disk originally is not locked, no action will be taken by the UNLOCK command. In any case no message will be displayed.

3.32

VER operating system version display

In MS-DOS7 and in MS-DOS8 the VER command (VERsion) shows version number of the corresponding WINDOWS software release. Having been supplied with /R parameter VER /R the VER command appends its version message with a remark about whether the DOS's kernel is loaded into high memory area or not.

65

Chapter 3: Internal commands 3.33 VERIFY verification function control

VERIFY command, being launched without parameters, indicates the state of verification function, which defines whether or not each written file should be re-read and compared with its origin. By default the verification function is turned OFF, and verification is not performed. You can change the state of verification function with VERIFY ON or VERIFY OFF commands (more about this in note 2 to 8.02-60). Note 1: high reliability of modern HDDs makes verification unnecessary, it leads to time loss and to excess disk wear. It is better to initialize verification by the /V parameter of COPY command (3.06) for copying file(s) only to diskette(s). Note 2: the VERIFY function acts as a global switch: it doesn't loose its state when current resident module of command interpreter finishes its job and local environment becomes lost.

3.34

VOL disks label and serial number

Disk's label is a string of up to 11 characters long, chosen by the user. If the user wouldn't define label while formatting, disk will be given the NO NAME label. Later disk's label may be changed with the LABEL.EXE utility (6.16) or by means of some TSR shells (Norton Commander, Volcov Commander, etc.). Serial number is a 8-digit hexadecimal identifier, which is automatically assigned to a disk during formatting procedure. Diskettes may have no serial number, if their production technology employs formatting by magnetic contact copying. Contrary to this during ordinary copying procedures both label and serial number are inherited by diskette-copy from diskette-origin. In order to display label and serial number of a particular disk, you have to specify its letter-name after the name of the VOL (= VOLume) command in the same command line, for example: VOL A: If disks letter-name is omitted, then volume label and serial number of the current disk will be displayed.

66

Chapter 4
4.01 4.02 4.03 4.04 4.05 4.06 4.07 4.08 4.09 4.10 4.11 4.12 4.13 4.14 4.15

Configuration commands
68 68 69 69 69 70 71 72 73 74 74 74 75 75 76 4.16 4.17 4.18 4.19 4.20 4.21 4.22 4.23 4.24 4.25 4.26 4.27 4.28 4.29 4.30 Installhigh LastDrive Lastdrivehigh MenuColor MenuDefault MenuItem Multitrack NUMLOCK REM Set Shell Stacks Stackshigh Submenu Switches 77 77 78 78 78 78 79 80 80 80 81 82 82 83 83

ACCDATE Break Buffers Buffershigh Country Device Devicehigh DOS DRIVPARM FCBS FCBSHIGH Files Fileshigh Include Install

MS-DOS7 loading configuration is prescribed by configuration options in three non-formatted textual files, which must be present in root directory of the bootable disk: MSDOS.SYS (5.01-01), CONFIG.SYS (9.01-01) and AUTOEXEC.BAT (9.01-02). Among these the CONFIG.SYS file has the most long history in previous versions of DOS. It defines a number of very important parameters and a set of software drivers to be loaded at boot time. Each line in CONFIG.SYS is a command to the IO.SYS loader (5.01-01). Interpretation of commands by the latter differs considerably from that by the most known command interpreter, the COMMAND.COM (6.04). There must be other commands and other syntax in CONFIG.SYS file. Though several configuration commands (4.02, 4.24, 4.25) are synonymous to those executed by the COMMAND.COM interpreter, the IO.SYS loader deals with them in a different way. The loader doesn't allow to omit file's suffixes, doesn't execute redirections, doesn't substitute variable's values for their names. Command execution order in CONFIG.SYS depends not only on line's order, but also on command's priorities (see 4.15 and 4.25 for details). There is a group of commands (4.19, 4.20, 4.21, 4.29), which can be specified in menu and submenu blocks only, and other commands (except 4.23) in these blocks can't be used. Several commands (4.01, 4.04, 4.11, 4.13, 4.18, 4.28) have no equivalents in previous versions of MS-DOS; some other commands (4.08, 4.30) have been changed in MSDOS7, new parameters have been added. Inherited configuration commands, which invoke

67

Chapter 4: Configuration commands


loading procedures, in MSDOS7 are treated otherwise as loading beyond conventional memory by default: DEVICE is executed just as DEVICEHIGH, BUFFERS as BUFFERSHIGH, and so on. If a certain driver must be loaded into conventional memory, implicit defaults should be discarded by specifying the NOAUTO parameter in DOS command (4.08). These and other peculiarities of configuration commands and of their interpretation by IO.SYS loader are described in detail in articles below.

4.01

ACCDATE registration of last access date

The ACCDATE command (ACCess DATE) enables or disables writing the date of last access into a directory entry (A.09-1), related to the accessed file. By default the last access date is registered in hard disk drives, but is not written on floppies. In a command line after the name of ACCDATE command you may specify any number of disks letter-names with following plus sign (= permit registration) or minus sign (= prohibit registration), for example: ACCDATE C+ D- E- RWhen access date registration is disabled, disk access operations are performed faster.

4.02

BREAK disk access intercept control

The BREAK command affects the state of a binary flag, which controls disk access intercepts. By default the BREAK flag is turned off, and then the BREAK and CTRL-C keystrokes (1.03) are checked only during the CON driver addressing operations. Hence the user can suspend or terminate execution of current procedure only when the latter addresses the CON driver: sends output to screen or waits for input from keyboard. The BREAK flag can be turned on with command: BREAK ON Since that moment the BREAK and CTRL-C keystrokes will be checked during disk access operations too. This gives an opportunity to suspend or to terminate execution of current procedure at the moments it addresses disk drives. Additional check makes disk operations a little slower. To disable the check the BREAK flag should be turned off with command: BREAK OFF After successful termination of IO.SYS loader's mission the BREAK command remains supported by command interpreter COMMAND.COM (3.01).

68

Chapter 4: Configuration commands 4.03 BUFFERS number of buffers

Command BUFFERS reserves memory for buffers each 512 bytes long, which serve as a cash for sectors read from disks. By default MS-DOS7 arranges 30 primary buffers and 0 secondary buffers. The BUFFERS command enables to create from 1 to 99 primary buffers and from 0 to 8 secondary buffers. Secondary buffers are needed when double buffering should be arranged by the DBLBUFF.SYS driver (5.06-02). For example, command BUFFERS=12,6 reserves 9 kb of memory for 12 primary and 6 secondary buffers. Disk reading and writing operations may become slow when number of buffers is less than 30. But when the SMARTDRV.EXE driver (5.06-01) is installed, then the number of buffers can be reduced to 10. Note 1: by default the buffers are created beyond the 640 kb boundary of conventional memory, but may be arranged below 640 kb, if in DOS command (4.08) the NOAUTO parameter is specified, and also if the address space in UMB region is insufficient or unavailable (availability conditions in 4.07). In any case no error message will be displayed. Note 2: in some computers the DMA controller can't provide access to UMB region or to its part, though the whole UMB region is opened by UMBPCI.SYS driver (5.04-04). In such computers it's better to arrange buffers outside UMB region: in conventional memory or in a space beyond 1088 kb, opened by EMM386.EXE driver (5.04-02). Sometimes this problem can be solved by auxiliary LOWDMA.SYS driver, supplied together with UMBPCI.SYS.

4.04

BUFFERSHIGH number of buffers in UMB address space

The BUFFERSHIGH command is almost equivalent to BUFFERS command (4.03), except that BUFFERSHIGH command attempts to arrange buffers beyond conventional memory despite presence of NOAUTO parameter in DOS command (4.08). All other information in article 4.03 is equally applicable to BUFFERSHIGH command.

4.05

COUNTRY loading national adaptation data

The COUNTRY command initializes selective copying of national adaptation data from COUNTRY.SYS data file (5.02-01) into internal DOS's data tables (A.02-4, A.02-5). Thus DOS settings become adapted to localized rules of a particular country. Besides other features, national adaptation enables access to files and directories having specific national characters inside their names. Here is an example of a line with COUNTRY command:

69

Chapter 4: Configuration commands


COUNTRY=007,866,C:\DOS\DRV\Country.sys where: 007 country code, in particular for Russia 866 number of codepage with Russian character set C:\DOS\DRV\ example of a path to Country.sys file Note 1: for other country codes and codepage numbers see appendix A.02-2

4.06

DEVICE loading a device driver

The DEVICE command is used to load those drivers, which have a header of special format (A.05-1) and should be loaded into memory when DOS's system structure arrangement is not finished yet. Most often (but not necessarily) these drivers are given the *.SYS suffix. Drivers with *.COM and *.EXE suffixes may have no special header, and then such drivers should be loaded not by DEVICE command, but by INSTALL command (4.15). Here is an example of a line with DEVICE command loading a driver with *.SYS suffix: DEVICE=C:\DOS\DRV\Himem.sys /EISA /V where: Himem.sys an example of drivers name C:\DOS\DRV\ an example of a path to the driver /EISA /V an example of a parameters group for the driver; it must conform to parameters specifications for this particular driver. Here is one more example of a DEVICE command loading another driver: DEVICE?=\DOS\DRV\Emm386.exe RAM /V Besides the driver itself, the latter string presents two differences. First, the path (\DOS\DRV\) without preceding disks letter-name is suitable for loading from any disk, even when the disks letter-name is not known beforehand. The second difference is an optional question mark "?", appended to the DEVICE command. This mark forces the IO.SYS loader to suspend further execution and to display the line, followed by a query whether to load the specified driver or not: [Enter=Y, Esc=N]? Thus the DEVICE command may be used to compose selective loading configurations. Note 1: by default the drivers are loaded beyond conventional memory (above 640 kb), but may be loaded below 640 kb, if in DOS command (4.08) the NOAUTO parameter is specified, and also if address space in UMB region is insufficient or

70

Chapter 4: Configuration commands


unavailable (availability conditions in 4.07). In any case no error message will be displayed. Note 2: DEVICE command can't be involved in address space optimization procedure in UMB memory region. If this feature is significant, the DEVICEHIGH command (4.07) should be used instead.

4.07

DEVICEHIGH loading a driver via UMB address space

The main purpose of DEVICEHIGH command is almost the same as that of the DEVICE command (4.06), but DEVICEHIGH command attempts to load drivers beyond conventional memory despite presence of NOAUTO parameter in DOS command (4.08). Of course, the UMB region address space must be made accessible beforehand. Therefore the following conditions must be met: computer must be equipped with 80386 or newer processor; the UMB parameter must be specified in DOS command (4.08); HIMEM.SYS driver (5.04-01) must be loaded yet by DEVICE command; either EMM386.EXE (5.04-02) or UMBPCI.SYS (5.04-04) driver must be loaded yet by DEVICE command in the following line of CONFIG.SYS file. When DEVICEHIGH command is used in its simplest form, for example DEVICEHIGH=C:\DOS\DRV\Setver.exe the specified driver (Setver.exe) will be loaded so that it could be addressed via that part of UMB region, which has the largest free block of address space, provided this free block is sufficient for the specified driver. Just as DEVICE command, the DEVICEHIGH command can be appended by a question mark: DEVICEHIGH?=... . It will cause this line to be displayed, then execution will be suspended with an offer for the user to decide whether the shown driver is to be loaded or not. The DEVICEHIGH command gives an opportunity to specify a particular area of UMB address space for access to the loaded driver, for example: DEVICEHIGH /L:1,15792 =C:\DOS\DRV\Display.sys CON=(EGA,,1) where: /L:1 15792 an example of UMB address space area number: it may be found from listing, shown by the MEM.EXE utility (6.17), being executed with /F parameter. optional size of address space to be devoted to the specified driver (generally it is not equal to driver's file size).

71

Chapter 4: Configuration commands


If a particular driver is composed of several parts, which can be addressed via different areas of UMB address space, then several address space areas may be allocated in one command, with or without size specification for each area, for example /L:2;3 or else /L:2,12192;3,3600 Note, that size is preceded by a comma, and different area specifications are separated by a semicolon. If size of the devoted area is specified, then the DEVICEHIGH command can accept optional /S parameter: DEVICEHIGH /L:1,35008 /S =C:\DOS\DRV\MOUSE.SYS The /S parameter means that allocated UMB block should be truncated to specified size. This leads to the most efficient address space usage, but doesn't guarantee from a crash, if size specification is not quite correct. Both block size and the /S parameter shouldn't be specified unless a memory allocation optimization procedure is performed by the MEMMAKER.EXE utility (5.04-03). As a result of this procedure both /S and /L parameters together with exact area specifications will be automatically written into each line with DEVICEHIGH command. Note 1: if address space in UMB region is insufficient or unavailable, then the DEVICEHIGH command will load driver(s) into conventional memory (below 640 kb), and no error message will be displayed.

4.08

DOS introduction of DOSs loading options

By default the core of MS-DOS7 is loaded into conventional memory. If the HIMEM.SYS driver is already installed, the DOS's core may be loaded into high memory region 1024 1088 kb. For this purpose the CONFIG.SYS file must contain a line with command DOS=HIGH Furthermore, if UMB address space is opened yet by either the EMM386.EXE driver (5.04-02) or by UMBPCI.SYS driver (5.04-04), then MS-DOS7 may be allowed to use UMB space for addressing DOS's system structures and drivers. This is achieved by command: DOS=UMB In MS-DOS7 one more optional parameter NOAUTO is introduced. It means that the IO.SYS loader must disable its defaults for implicit loading of several drivers (HIMEM.SYS, DBLBUFF.SYS, IFSHLP.SYS, DBLSPACE.SYS) as well as for loading beyond 640 kb with ordinary loading commands DEVICE, INSTALL and some others

72

Chapter 4: Configuration commands


(4.03, 4.06, 4.10, 4.12, 4.15, 4.17, 4.27). In fact the NOAUTO parameter enables to configure MS-DOS7 as a separate operating system. All parameters of the DOS command may be specified in one line: DOS=HIGH,UMB,NOAUTO Note 1: the DOS command can accept one more parameter SINGLE, which enables to load MS-DOS7 when otherwise the Windows-95/98 OS were loaded. But this way to load MS-DOS7 is accompanied with inappropriate questions to the user and entails increased risk to fall into reboot. Therefore other methods of loading MS-DOS7 should be preferred, those which are enlisted in article 1.03.

4.09

DRIVPARM replacement of drives parameters

The DRIVPARM command (DRIVe PARaMeters) is a means to provide access to storage media in those devices, which can't be identified properly by PC's BIOS. In fact those devices are implied, which were known yet to MS-DOS7 at the moment of it's release in 1996, but were not known to BIOS of obsolete computers, produced in early 1990-ties or even earlier. Here is an example of DRIVPARM command usage for providing access to a 3,5-inch floppy drive in an old PC with BIOS support only for 5,25-inch floppy drives: DRIVPARM /D:1 /c /f:7 /h:2 /i /s:18 /t:80 where: /D:1 /c /f:7 specifies physical drive number, "1" means drive B:, "0" should be used for drive A:, "2" - for drive C:, and so on. optional parameter, enabling removable media change detection. For non-removable media the "/n" parameter should be specified instead. defines type number of the drive: 0 160/180/320/360 kb 5,25 inch drive; 1 1.2 Mb 5,25-inch drive; 2 720 kb 3.5-inch drive; 5 hard disk drive; 6 magnetic tape device (streamer); 7 1.44 Mb 3.5-inch drive; 8 optical disk drive; 9 2.88 Mb 3.5-inch drive. defines number of heads, default is 2 for double-sided diskettes. support for 3.5-inch drives if these are not supported by BIOS. specifies number of sectors per track 8 for old 320 kb 5.25-inch diskettes; 9 for 360 kb and 720 kb diskettes; 15 for 1.2 Mb 5.25-inch diskettes;

/h:2 /i /s:18

73

Chapter 4: Configuration commands


18 for 1.44 Mb 3.5-inch diskettes. specifies number of tracks 40 for old 360 kb diskettes; 80 for 720 kb and 1.44 Mb diskettes.

/t:80

Note 1: default settings for /f and /s parameters correspond to 5.25-inch diskettes with 9 sectors per track.

4.10

FCBS number of file control blocks

The FCBS command (File Control BlockS) reserves memory for a specified number of file control blocks from 1 to 255, each 80 bytes long. FCBS is an obsolete form, providing access to open files in current directory only. FCBS can't be applied to media having FAT32 file system. Modern DOS programs use "file handles" (4.12) instead of FCBS. Nevertheless MS-DOS7 supports FCBS, because they are used by some oldfashioned programs and network services (INTERLNK.EXE, SHARE.EXE, etc.). In most cases the default value FCBS=4 is quite enough. Note 1: by default a place for FCBS is reserved beyond conventional memory (above 640 kb), but may be reserved below 640 kb, if in DOS command (4.08) the NOAUTO parameter is specified, and also if the address space in UMB region is insufficient or unavailable (availability conditions - in 4.07). In any case no error message is displayed. Note 2: the FCBS specification doesn't limit available number of "unopened" file control blocks (A.09-5), which are used inside PSP (A.07-1), and also by some file search procedures.

4.11

FCBSHIGH file control blocks in UMB address space

The FCBSHIGH command is almost equivalent to FCBS command (4.10), except that FCBSHIGH command attempts to arrange file control blocks beyond conventional memory despite presence of NOAUTO parameter in DOS command (4.08). All other information in article 4.10 is equally applicable to FCBSHIGH command.

4.12

FILES reservation of SFT entries

The FILES command reserves address space for a specified number of SFT table entries (A.01-4). Each entry defines state of an opened object a file or a channel, and also defines association of this object with its numerical reference, the so called "handle" used

74

Chapter 4: Configuration commands


to address the object. By default there is 60 entries in SFT. This number of entries is often excessive. For ordinary work you may need FILES=30 SFT with 30 entries takes about 1800 bytes. For operating with large databases the number of SFT entries should be increased to 40. Note 1: by default a place for SFT entries is reserved beyond conventional memory (above 640 kb), but may be reserved below 640 kb, if in DOS command (4.08) the NOAUTO parameter is specified, and also if address space in UMB region is insufficient or unavailable (availability conditions in 4.07). In any case no error message is displayed.

4.13

FILESHIGH number of SFT entries in UMB address space

The FILESHIGH command is almost equivalent to FILES command (4.12), except that FILESHIGH command attempts to arrange SFT entries beyond conventional memory despite presence of NOAUTO parameter in DOS command (4.08). All other information in article 4.12 is equally applicable to FILESHIGH command.

4.14

INCLUDE reference to a block of commands

The INCLUDE command inserts a named block of commands into general succession of configuration commands to be executed. The inserted block of commands may be placed elsewhere inside the same CONFIG.SYS file, but it must be announced in its first line by a unique block name a word or a number, enclosed in square brackets, for example, [L055] (example is taken from 9.09-01). End of the block must be marked with similar line, containing a name of the next block. If there is no need to specify other blocks, a line with reserved name [common] should be specified afterwards. All commands following a line with this name (if there are any) will be executed in each specified configuration. In order to execute commands, in particular, of the block [L055], in the desired position in CONFIG.SYS file there must be a line INCLUDE=L055 Note that name of the block should be specified to the right of equality sign without enclosing square brackets. If the same block of commands should be executed in several loading configurations, then each configuration specification must contain identical lines with INCLUDE command. Segregation of repeated command sequences into separate blocks makes the structure of CONFIG.SYS file simpler and more clear. Examples of such CONFIG.SYS file's structures are shown in articles 9.04-01, 9.09-01 and 9.11-03.

75

Chapter 4: Configuration commands 4.15 INSTALL loading a TSR executable

The INSTALL command is used to load program's resident modules and those drivers, which have no special header (A.05-1) and therefore can't be loaded with DEVICE (4.06) or DEVICEHIGH (4.07) commands. Most often such drivers are marked with suffix *.COM or *.EXE. Drivers and utilities to be loaded with INSTALL command must meet the following conditions: they must not need environment space; they must not send calls for handling critical errors; they must not rely on services of COMMAND.COM interpreter, which is not loaded yet at that time. The mentioned conditions are satisfied, though, by a large part of those drivers and TSR utilities, which are designed to be loaded from AUTOEXEC.BAT file or from command line. Loading from CONFIG.SYS file with INSTALL command is considered more reliable and takes a little less memory space. Lines with INSTALL command are interpreted after all lines with DEVICE, DEVICEHIGH and SET commands, but before the line with SHELL command, even if succession of lines in CONFIG.SYS file is different. Contradiction between sequence of lines and sequence of execution can cause confusion and therefore should be avoided. Preferable line's order must correspond to sequence of execution. Here is an example of a line with INSTALL command: INSTALL=\DOS\DRV\Mkecdex.com /B /L:0 In the shown line to the right of equality sign there are path to the driver, driver's name and a group of its parameters. Just like the DEVICE command (4.06), the INSTALL command may be appended with question mark (INSTALL?=...), enabling the user to see this line on the screen and make a choice ([Enter=Y, Esc=N]) about whether to execute it or to skip. The INSTALL command can be used for temporary loading of those modules, which are to be uninstalled after termination of their mission. Peculiarity of such operations is that DOS automatically releases occupied memory space within conventional memory only, below 640 kb. When the NOAUTO parameter is specified in DOS command (4.08), then the INSTALL command will load modules into conventional memory, and then, therefore, you can afford temporary loading of command interpreter module in order to suspend execution for a while and give an opportunity to read displayed messages: INSTALL=C:\Command.com /low /c pause One more example of command interpreter's temporary loading with INSTALL command is shown in article 9.09-01. Note 1: unlike the DEVICEHIGH command, INSTALL command is not involved in memory allocation optimization procedure, performed by MEMMAKER.EXE

76

Chapter 4: Configuration commands


(5.04-03). Because of this reason the INSTALL command doesn't allow to affect memory allocation with auxiliary parameters /L and /S (4.07). Note 2: by default the drivers and TSR modules are loaded beyond the conventional memory (above 640 kb), but may be loaded below 640 kb, if in DOS command (4.08) the NOAUTO parameter is specified, and also if address space in UMB region is insufficient or unavailable (availability conditions in 4.07). In any case no error message is displayed.

4.16

INSTALLHIGH loading a TSR via UMB address space

The INSTALLHIGH command is almost equivalent to INSTALL command (4.15), except that INSTALLHIGH command attempts to load drivers and TSR modules beyond conventional memory despite presence of NOAUTO parameter in DOS command (4.08). The INSTALLHIGH command shouldn't be used for loading those modules, which are to be uninstalled after termination of their mission. All other information in article 4.15 is equally applicable to INSTALLHIGH command.

4.17

LASTDRIVE reservation of CDS entries

The LASTDRIVE command defines number of entries in DOS's CDS table (A.03-03). Entries in CDS table store names of current directories for logical disks, both real and virtual. At boot time MS-DOS7 creates one valid CDS entry record per each logical disk, identified by PC's BIOS system, and then appends CDS structure with dummy entries (reservations). The last entry corresponds to the last disks letter-name, specified by LASTDRIVE command. By default MS-DOS7 assumes LASTDRIVE=Z Such CDS table with 26 entries occupies 2288 bytes. If you consider this excessive, you may specify other disks letter-name by LASTDRIVE command, but in any case there must be enough CDS entries for all logical disks, including those which will be made accessible later, after installation of CD-ROM drivers, network services, etc. Note 1: by default CDS table is arranged beyond conventional memory (above 640 kb), but may be arranged below 640 kb, if in DOS command (4.08) the NOAUTO parameter is specified, and also if address space in UMB region is insufficient or unavailable (availability conditions in 4.07). In any case no error message is displayed.

77

Chapter 4: Configuration commands 4.18 LASTDRIVEHIGH CDS entries in UMB address space

The LASTDRIVEHIGH command is almost equivalent to LASTDRIVE command (4.17), except that LASTDRIVEHIGH command attempts to arrange CDS table beyond conventional memory despite presence of NOAUTO parameter in DOS command (4.08). All other information in article 4.17 is equally applicable to LASTDRIVEHIGH command.

4.19

MENUCOLOR menu color choice

The MENUCOLOR command may be used optionally only in those blocks of configuration commands, which are named [menu] or are announced as submenu in their parent menu or submenu. Color palette for each menu or submenu may be set by a separate MENUCOLOR command, specified in this menu or submenu. The default color settings are equivalent to command: MENUCOLOR=7,0 In the shown example the first digit means code of text color (7 white), and the second digit (after comma) means code of background color (0 black). You are allowed to choose other colors. All permissible color codes together with their meanings are enlisted in appendix A.10-5.

4.20

MENUDEFAULT choice of default menu item

The MENUDEFAULT command may be used only in those blocks of configuration commands, which are named [menu] or are announced as submenu in their parent menu or submenu. The MENUDEFAULT command is placed in the last line of menu block and defines that menu item, which should be chosen automatically if the user has not made his choice during a prescribed time, for example: MENUDEFAULT=L007,20 In the shown example the first group of characters just after equality sign means a name of configuration block [L007], which is to be chosen by default, and a number after comma means 20 seconds waiting for the user's choice before automatic default choice will be made. Delays from 0 to 99 seconds are allowed. Examples of configuration menu with MENUDEFAULT command are shown in articles 9.04-01, 9.09-01, 9.11-03.

4.21

MENUITEM specification of menu entry

The MENUITEM command may be used within the first menu block of commands (named [menu]) in CONFIG.SYS file and in those blocks, which are announced as

78

Chapter 4: Configuration commands


submenu in their parent menu or submenu. Each alternative, presented in menu or in submenu, must be linked with corresponding block of configuration commands and must be given an intelligible title. This is just what is done by MENUITEM command, for example: MENUITEM=L007, Relocate DOS to 5600 kb RAM-disk R: In the example above the "L007" is a name of a block of commands (taken from 9.09-01), which must be present in CONFIG.SYS file and must be preceded by a header line with the same name [L007] in square brackets (2.03-05). The rest part of the shown command line (after comma) is a title text, representing this menu entry on the screen. Title text may include spaces between words, but square brackets [ ], semicolons ( ; ) and slashes ( / \ ) are not allowed. During interpretation of menu block the IO.SYS loader creates an environmental variable CONFIG and assigns as its value the name of the chosen configuration block ( L007 in the shown example). This value may be used later in order to adapt execution of AUTOEXEC.BAT file (or any other batch file as well) according to the chosen configuration. Note 1: total number of MENUITEM and SUBMENU (4.29) commands in each menu block must not exceed 9.

4.22

MULTITRACK drive addressing mode

For access to a disk, DOS must specify starting sector and a number of sectors to be read (or written). In obsolete PCs produced in early 1980-ties disk drives and BIOS versions performed access operations within one track at a time, so that the sum of starting sector number and the number of sectors to be accessed could not exceed total number of sectors on a track (otherwise the process was "wrapped" to the beginning of the same track). Being forced to cope with obsolete hardware, MS-DOS7 also couldn't afford multitrack addressing, and then the CONFIG.SYS file must contain a line MULTITRACK OFF Since late 1980-ties all disk drives and BIOS versions are able to prevent the mentioned wrapping: access automatically is switched to the next track. This gives an opportunity to address several tracks in one operation and makes disk access much faster. MS-DOS7 performs multitrack access and in fact takes MULTITRACK ON option as default. Therefore now the MULTITRACK command is almost always omitted.

4.23

NUMLOCK numerical keypad state control

The NUMLOCK command (NUMerical keypad LOCK) defines status of numerical keypad (at the right edge of standard keyboard). Most often the NUMLOCK switch is kept

79

Chapter 4: Configuration commands


OFF, and then the numerical keypad keys duplicate functions of keys in main part of keyboard (arrows, PgUp PgDn, etc.). If other status should be avoided, the CONFIG.SYS file must contain command NUMLOCK OFF In order to enable input of digits and arithmetic symbols the NUMLOCK status should be reversed with command NUMLOCK ON Either state of NUMLOCK switch is suitable for choosing items in configuration menu. While NUMLOCK is OFF, you may scroll selection up-down as with arrow keys, but when NUMLOCK is set ON, you may select items in configuration menu by their number, entered via numerical keypad. Note 1: NUMLOCK switch state affects key codes, returned by INT 16\AX=10h (8.01-83). More about this in note 6 to appendix A.02-1.

4.24

REM remark line

REM command (REMark) forces the IO.SYS loader to ignore all following words up to the end of line. Main purpose of REM command is to provide an opportunity to specify comments, which should not be displayed on the screen. Insertion of the REM command at the start of any command line enables to skip this line during interpretation of CONFIG.SYS file. Note 1: during interpretation of lines in CONFIG.SYS file the IO.SYS loader doesn't provide those extra opportunities, which are provided by the COMMAND.COM interpreter for its synonymous REM command (3.24).

4.25

SET value assignment to a variable

The SET command in CONFIG.SYS file is used to assign or to redefine a value of an environmental variable, for example: SET Var_Name=New_Var_Value where: Var_name a name example of environmental variable; it must begin with a letter and may contain digits. New_Var_Value an example of a string value for the named environmental variable; it must not contain equation sign(s) inside. If there are spaces in the value, preceding the value or following the value (up to the end of line mark), all these spaces will be included in the assigned value.

80

Chapter 4: Configuration commands


The SET command, executed by IO.SYS within CONFIG.SYS file, causes a bit different effect than synonymous command (3.25), executed by COMMAND.COM interpreter from command lines or in batch files. The differences are: when used without following variable's parameters, the SET command in CONFIG.SYS file doesn't display the current environment. in CONFIG.SYS file the SET command, appended with a question mark (SET?=...), causes execution to stop with a query [Enter=Y, Esc=N], thus enabling the user to make a choice on whether to execute this line or not. SET commands in CONFIG.SYS file are performed after all DEVICE and DEVICEHIGH commands, but before execution of INSTALL, INSTALLHIGH and SHELL commands. This is a reason to prefer this order of lines in CONFIG.SYS file. aliases (2.03-03), redirections (2.04-02 2.04-05) and value substitutions in CONFIG.SYS file are not performed. Hence any symbol of redirection and substitution can be included in a value of a variable, assigned by the SET command in CONFIG.SYS file.

4.26

SHELL interpreter shell specification

The SHELL command is used to launch an executable file, which will not return control back to IO.SYS loader. This is why SHELL command is executed the last in CONFIG.SYS file, and preferably should be specified in its last line. Executables loaded with the SHELL command may be loaders of other operating systems (as LOADLIN.EXE for LINUX OS) or command interpreters, which are to take control over PC after the IO.SYS loader finishes its job. Here is an example of control transfer to command interpreter NDOS.COM: SHELL=C:\DOS\NU\Ndos.com /f @C:\DOS\NU\Ndos.ini where: C:\DOS\NU\ is an example of a path to command interpreter file; /f @C:\DOS\NU\Ndos.ini an example of parameters string for NDOS.COM command interpreter. When the SHELL command isn't present in CONFIG.SYS file, the IO.SYS loader attempts to find the MS-DOS's proprietary command interpreter COMMAND.COM in the root directory of the current disk. In this case the COMMAND.COM interpreter will be launched with default parameters. It is better, though, to specify parameters explicitly, for example: SHELL=Command.com A:\ /e:1008 /p

81

Chapter 4: Configuration commands


In the latter example absence of a path before interpreter's name implies its presence in the current directory. Parameter's assignments for COMMAND.COM interpreter are described in detail in 6.04. Other examples of control transfer to the COMMAND.COM interpreter are shown in articles 9.01-01, 9.04-01 and 9.09-01.

4.27

STACKS number of auxiliary stacks

The STACKS command in CONFIG.SYS file specifies number of auxiliary DOS's stacks used for treatment of nested interrupts. Parameters of STACKS command define a number of auxiliary stacks and amount of address space devoted for each stack. The default parameters are equivalent to command STACKS=9,256 where: 9 256 number of auxiliary stacks (from 8 to 64 and 0 are allowed); size of each auxiliary stack in bytes (from 32 to 512 and 0 are allowed).

Since each stack overflow fault forces to reboot the PC and may cause data loss, the actual size of auxiliary stacks should not be less than the default value. Note 1: by default auxiliary stacks are arranged beyond the conventional memory (above 640 kb), but may be arranged below 640 kb, if in DOS command (4.08) the NOAUTO parameter is specified, and also if address space in UMB region is insufficient or unavailable (availability conditions in 4.07). In any case no error message is displayed.

4.28

STACKSHIGH number of stacks in UMB address space

The STACKSHIGH command is almost equivalent to the STACKS command (4.27), except that STACKSHIGH command attempts to arrange auxiliary stacks beyond conventional memory despite presence of NOAUTO parameter in DOS command (4.08). All other information in article 4.27 is equally applicable to STACKSHIGH command.

4.29

SUBMENU introduction of a submenu

The SUBMENU command announces a menu entry, just as the MENUITEM command (4.21), but unlike the latter, the SUBMENU command forces to treat the corresponding block of commands as a submenu. Of course, the SUBMENU command itself may be used only in those blocks of configuration commands, which are named [menu] or are announced as submenu in their parent menu or submenu, for example:

82

Chapter 4: Configuration commands


SUBMENU=6000, Relocation to RAM-disk In the shown example "6000" means a name of corresponding configuration block, and words after comma denote title text for the proposed menu entry. This text is subjected to the same restrictions as text in MENUITEM command (4.21). Submenu configuration block (named [6000] in the shown example) must have the same structure as the main menu block and may include up to 9 entries, each represented by a separate line with MENUITEM or SUBMENU command. The main specific feature of submenu block is its name: it must be unique and must differ from reserved names [menu] and [common].

4.30

SWITCHES supplementary options

The SWITCHES command enables to specify up to four optional configuration items, for example: SWITCHES= /K /N /F /E:64 where: /K /N /F /E:64 enables old programs, consigned for 86-key keyboard, to cope with newer "enhanced" 101/108-key keyboard. disables opportunity to skip execution of configuration files (CONFIG.SYS and AUTOEXEC.BAT) with F5 and F6 keys. excludes two-second delay after displaying the message "Starting WINDOWS...". allots 64 bytes of conventional memory (from 48 to 1024 bytes allowed) to a "handle" for EBIOS, which is BIOS system extension, enabling LBA access to HDDs (see note 4 to A.13-6). If the number after /E parameter is omitted, then the whole EBIOS code, if it will be found necessary, will be loaded into conventional memory. In modern PCs the /E parameter is not needed, because LBA access is supported by their main BIOS system.

83

Chapter 5

Selected drivers for MS-DOS7

Drivers are files with executable resident code inside. Resident code is the code adapted for being written into RAM (random accessed memory) and left there, waiting for its chance of being requested on certain occasion(s). When this particular occasion happens, driver's code is executed, performs its mission and then again is left waiting for the next request. This mode of action is similar to the "life" of operating system's core. MS-DOS combines a limited number of main core's functions with various functional extensions, provided by drivers. Proper choice and renewal of drivers is an important factor for DOS's survival amongst ever changing PC's hardware. Drivers may be presented in a form of files with special header (A.05-1), most often marked with *.SYS suffix, or in a form of ordinary executable files (*.COM or *.EXE) having a TSR (Terminate and Stay Resident) part. Drivers with *.SYS suffix must be loaded by DEVICE (4.06) or DEVICEHIGH (4.07) commands from lines of configuration file CONFIG.SYS. Composition examples for CONFIG.SYS file are shown in articles 9.01-01, 9.04-01 and 9.09-01. Loading by DEVICE or DEVICEHIGH commands gives more chances to affect DOS system structures construction, because it is not finished yet at that moment. Drivers with *.COM and *.EXE suffixes usually are loaded later either from CONFIG.SYS file with INSTALL (4.15) or INSTALLHIGH (4.16) commands, or from AUTOEXEC.BAT file (9.01-02, 9.04-02, 9.09-02), or from command line - directly or with LH command (3.17). Loading from CONFIG.SYS file is less subjected to mutual software interference and therefore is considered more safe. On the other hand, INSTALL and INSTALLHIGH commands can't be involved in memory optimization procedure by MEMMAKER.EXE optimizer. If memory optimization is significant, loading with LH command from AUTOEXEC.BAT file should be preferred. The main group of drivers for MS-DOS7 constitute those supplied within WINDOWS-95/98 operating system release and on its rescue diskette. In case of standard operating system installation all drivers for MS-DOS7 are in directories \WINDOWS and \WINDOWS\COMMAND. But if MS-DOS7 is installed as an independent operating system, it's better to arrange a separate directory for drivers, for example, C:\DOS\DRV. This path is shown in the most part of presented examples. When you will intend to follow these examples in practice, it's important to remember: the path you specify must not be necessarily C:\DOS\DRV, it must be exactly the one that leads to each particular driver in your particular computer. Beside "native" Microsoft's drivers, a lot of drivers for MS-DOS7 have been developed since 1995 by other software vendors and by manufacturers of PC's hardware. Existing

84

Chapter 5 Selected drivers for MS-DOS7


drivers are too numerous, and only a limited selection of them can be described here. The following text doesn't include descriptions of some other Microsoft's drivers (that can be found in MSDOSDRV.TXT, supplied with WINDOWS-95 software release) as well as of drivers for some non-common equipment (MO, PD and ZIP drives, LS120 floppies, streamers, etc.). Preference has been given to those drivers which are the most necessary for reparatory works.

5.01
5.01-01

DOSs system services


The core file IO.SYS and parameters file MSDOS.SYS

In the root directory of the disk used to load WINDOWS-95/98 or MS-DOS7, there are two hidden system files: IO.SYS and MSDOS.SYS. These files are there since installation of the operating system, they implement its loading. File IO.SYS combines the core of MS-DOS7 with interpreter and with DOS loader. The MSDOS.SYS file contains a set of loading parameters. If you have no such files, you may get them from a disc with WINDOWS-95/98 release, or else you may download them, for example, packed into archive DOS7.ZIP from internet site http://www.micosyen.com/msdos.php . In order to make a disk bootable with MS-DOS7, presence of the mentioned system files is necessary, but not sufficient. Boot-sector's executable code will not "know" where control should be transferred, unless the name of loader is written into boot-sector. This is why copying of system files is combined with boot-sector updating in joint mission of SYS.COM utility (6.24). Having got control over booting process, DOS loader reads loading parameters from MSDOS.SYS file. These parameters define the alternatives, described in article 1.02, and also define which operating system should be loaded: MS-DOS7 or WINDOWS-95/98. If the HRS attributes (H = Hidden, R = Read-only, S = system) of the MSDOS.SYS file are taken off by the ATTRIB.EXE utility (6.01), then MSDOS.SYS becomes an ordinary nonformatted textual file, which can be opened, changed and rewritten with editor utility, for example, with EDIT.COM (6.09). Several or even all parameters may be not specified in MSDOS.SYS file, and then the omitted parameters will be given the default values. Contrary to other system files, MSDOS.SYS is not copied by SYS.COM utility, but rather is created empty anew, and this doesn't hamper normal loading of WINDOWS-95/98 operating system. At least some of the default parameter's values wouldn't fit, though, if you intend to load MS-DOS7 as a stand-alone operating system. Suitable values of all parameters are shown in an example of MSDOS.SYS file presented below.

85

Chapter 5 Selected drivers for MS-DOS7


[Paths] WinDir=C:\WINDOWS ; path for environmental variables TMP, TEMP and PATH WinBootDir=C:\WINDOWS ; path for environmental variable WINBOOTDIR HostWinBootDrv=C ; announcement of the disk used to boot the PC [Options] Logo=0 ; hide loading messages under logo (= 1) or not (= 0) BootMenu=0 ; display Windowss boot menu (= 1) or not (= 0) BootMenuDelay=20 ; delay in seconds of default menu item choice BootMenuDefault=1 ; menu item number to be chosen as default BootKeys=1 ; enable (= 1) or disable (= 0) the "hot keys" F5, ; Shift-F5, F6, F8 and Shift-F8, described in article 1.02 BootDelay=2 ; waiting time (in seconds) for "hot key" keystroke BootMulti=0 ; disable the F4 key (1.02) for previous DOS version BootWin=1 ; load MS-DOS7 and Windows (= 1) or previous DOS (= 0) BootSafe=0 ; load Windows in ordinary (= 0) or in safe mode (= 1) BootWarn=0 ; dont warn about loading Windows in safe mode BootGUI=0 ; load Windows with its GUI (= 1) or MS-DOS7 (= 0) LoadTop=0 ; load Command.com and Dblspace.bin below 640 kb AutoScan=0 ; Scandisk.exe automatic launching conditions: ; never launch automatically (= 0), ; launch after each identified failure (= 1) ; launch during each PC loading procedure (= 2) DBLSpace=0 DRVSpace=0 ; dont load compression on-the-fly drivers. Otherwise ; value = 1 may be specified for one such driver only Network=0

86

Chapter 5 Selected drivers for MS-DOS7


; load (= 1) or dont load (= 0) network support DoubleBuffer=0 ; cancel default loading of Dblbuff.sys driver (5.06-02) DisableLog=1 ; dont write loading report into Bootlog.txt file. Lines of the MSDOS.SYS file are read by an interpreter, integrated into the same IO.SYS file. The interpreter ignores all lines starting with semicolon, and this is why such lines are used to insert comments. Of course, lines with comments can be omitted, but there is one argument against it: for compatibility with obsolete antivirus programs the length of hidden system files must be not less than 1024 bytes. For most modern antivirus programs this restriction is not significant. All parameter's values in the shown example of MSDOS.SYS file are compatible with variants of configuration files, presented in articles 9.01, 9.04, 9.09 and 9.11. Settings in the [PATHS] section are taken into account by WINDOWS operating system only; for MS-DOS7 the corresponding values of environmental variables should be ignored or reassigned later, during interpretation of the second configuration file - AUTOEXEC.BAT. A large part of parameters in the [OPTIONS] section can be omitted too. Nevertheless the shown complete list of parameters will help you to decide, whether any particular parameter should be specified and which value it should be given. Having prepared your own version of MSDOS.SYS file, don't forget to return back its original attributes HRS (Hidden, Read-only, System). In accordance with the prepared parameters the DOS loader loads the core of MS-DOS7. The core is responsible for system DOS services and for main INT 21 handlers, described in part 8.02. The last loader's mission is execution of commands from configuration file CONFIG.SYS, which define loading of most drivers. Several variants of CONFIG.SYS file are shown in articles 9.01-01, 9.04-01 and 9.09-01. Later MS-DOS7 never calls the IO.SYS file for execution, but its presence is nevertheless necessary for copying each time, when you have to make bootable any other disk. Note 1: in earlier versions of MS-DOS the MSDOS.SYS file was not a textual file, it contained the core of DOS and was loaded almost as an ordinary driver. Note 2: In 2001 a bug has been revealed in the core of MS-DOS7: it didn't cope properly with HDD's LBA-errors. Therefore Microsoft issued a patched core file IO.SYS inside SFX-archive 311561usa8.exe. The latter can be downloaded from http://support.microsoft.com/kb/311561/en-us?spid=6519&sid=global . WINRAR version 3.2 (or higher) unpacks 311561usa8.exe as CAB-archive. Two subversions of IO.SYS file are hidden there under nicknames Winboot.98s and Winboot.98g. If the VER command (3.32) reports version 4.10.2222, then IO.SYS should be obtained by renaming Winboot.98s. If reported version is 4.10.1998, then Winboot.98g should be similarly renamed and used as IO.SYS.

87

Chapter 5 Selected drivers for MS-DOS7


5.01-02 DOS version number substitution: driver SETVER.EXE

Evolution of OS versions is complicated by a problem of application programs, which have been developed for previous versions of DOS. Compatibility of any application with future OS versions is a matter of faith rather than prediction. Microsoft suggested to solve this problem by informing definitely compatible application programs via INT 21\AH=30h (8.02-22) about not the actual, but the required DOS version number. SETVER.EXE is just that driver, which is charged with mission of deceiving application programs by substitution of DOS version number. In case of standard installation of WINDOWS-95/98 the SETVER.EXE driver is in the \WINDOWS directory. But if you want to use MS-DOS7 separately, it's better to have a copy of SETVER.EXE in common directory with other DOS drivers. It has to be loaded by DEVICE (4.06) or DEVICEHIGH (4.07) command from a line of CONFIG.SYS file: DEVICEHIGH=C:\DOS\DRV\Setver.exe where: C:\DOS\DRV\ is a path example to SETVER.EXE driver stored in separate directory for DOS drivers. Application program will receive the substituted DOS version number only if the name of this program together with the required DOS version number is in advance registered in internal versions table inside the loaded TSR module of SETVER.EXE driver. Though such substitution doesn't guarantee a proper outcome, nevertheless most old programs are able to operate properly in MSDOS7. The SETVER.EXE driver can be launched from command line just as an ordinary utility, for example, in order to display its short help text: Setver.exe /? Being run from command line without parameters, SETVER.EXE driver displays its internal table of versions. Originally table of versions is not empty: its entries reflect Microsoft's recommendations. In order to append the table of versions with one more entry you should type Setver.exe Qbasic.exe 6.22 where: Qbasic.exe name example of the utility to be "deceived". The name must have suffix *.COM or *.EXE. 6.22 an example of required DOS version number. Command to delete the same entry from internal table of versions requires the /D parameter and looks as Setver.exe Qbasic.exe /D

88

Chapter 5 Selected drivers for MS-DOS7


After any operation with its internal table the SETVER.EXE driver leaves one of the following errorlevel values (more about errorlevels in 3.15-03 and in 9.07-03): 0 successful completion 1 invalid command line switch specification 2 invalid filename specification 3 no memory enough to carry out the command 4 invalid version number format 5 specified entry isn't found in the table of versions 8 too many parameters in command line 9 one or more necessary parameters are missing 10 an error detected while reading the table of versions 11 the table of versions is corrupt 13 no more space in table of versions for a new entry 14 an error while writing SETVER.EXE with new table All successful operations affecting contents of internal table are finished in the same way: former internal table on a disk is overwritten with its updated variant, containing changed entries. But writing the changes in a file on a disk is not enough to make them active. They will become active when the changed table of versions is transferred from a file into driver's TSR module, loaded into memory by DEVICE or by DEVICEHIGH command. This is why the changes come into effect only after PC's reboot.

5.02
5.02-01

National adaptation drivers


COUNTRY.SYS specifications data file

In case of standard installation of WINDOWS-95/98 OS the COUNTRY.SYS file can be found in \WINDOWS\COMMAND directory. COUNTRY.SYS is in fact a set of data tables, one of which is to be loaded from CONFIG.SYS file with special COUNTRY command (4.05), for example: COUNTRY=007,866,C:\DOS\DRV\Country.sys where: 007 country code (A.02-2), in particular for Russia; 866 number of codepage (A.02-2), defining character set for Russia; C:\DOS\DRV\ path example to file COUNTRY.SYS, copied into common directory for DOS drivers. Having been loaded, data from COUNTRY.SYS change several internal DOS settings, related to country-specific conventions on displaying time, dates, currency and punctuation

89

Chapter 5 Selected drivers for MS-DOS7


symbols, character sorting and national restrictions on character set for names (A.02-5). The latter feature is of special importance, since otherwise the files, having national characters in their names, may become inaccessible. 5.02-02 DISPLAY.SYS character generator driver

DISPLAY.SYS driver prepares memory buffers for one or more national codepage tables, specifying character set and outline (A.02-2). Normally the DISPLAY.SYS driver can be found in \WINDOWS\COMMAND directory. This driver must be loaded by a DEVICE (4.06) or DEVICEHIGH (4.07) command from a line in CONFIG.SYS file: DEVICE=C:\DOS\DRV\Display.sys CON=(EGA,866,2,1) where: C:\DOS\DRV\ example of a path to DISPLAY.SYS driver, copied into special directory for DOS drivers. CON (console) specification of display as output device (no alternative). EGA means that PC is equipped with EGA, VGA or SVGA video card; alternatives to EGA type are: LCD video module used in obsolete portable PCs (notebooks); CGA obsolete color video card without codepage switching; MONO obsolete monochrome MDA video card, also without codepage switching. When type of video card is omitted, then DISPLAY.SYS driver will try to determine it, but this leaves a chance for mistake. 866 number of primary codepage (A.02-2), this one is in particular for Russia. Several codepages are supplied in each of the files EGA.CPI, EGA2.CPI, EGA3.CPI and ISO.CPI. Later the MODE.COM utility (6.18) enables to select proper codepage and write it into memory buffer prepared by DISPLAY.SYS driver. 2 number of memory buffers to be prepared for character sets, besides the one prepared for the primary character set, specified by preceding codepage number. From 0 to 6 auxiliary buffers are allowed for EGA, VGA and SVGA video cards, no more than 1 for LCD video modules, and only 0 for CGA and MDA video cards. 1 number of hardware supported fonts for each codepage. This number may be omitted together with preceding comma. Default is 1 for LCD type and 2 for EGA, VGA and SVGA video cards. Note 1: all parameters in parenthesis may be omitted (brackets left empty), and then DISPLAY.SYS driver will appoint default settings. Note 2: TSR module of DISPLAY.SYS driver is opened for interaction with programs via INT 2F\AX=AD00-AD03h (8.03-26, 8.03-27).

90

Chapter 5 Selected drivers for MS-DOS7


5.02-03 NLSFUNC.EXE codepage switch

The NLSFUNC.EXE driver activates CHCP command (3.04) for switching between different codepages, coordinated with changing of other national settings. Normally this driver can be found in \WINDOWS\COMMAND directory. The NLSFUNC.EXE driver may be loaded directly or with LH command (3.17) from command line or from AUTOEXEC.BAT file, or else from CONFIG.SYS file with INSTALL (4.15) or INSTALLHIGH (4.16) command, for example: INSTALLHIGH=C:\DOS\DRV\Nlsfunc.exe C:\DOS\DRV\Country.sys where: C:\DOS\DRV\ path example to NLSFUNC.EXE driver, copied into common directory for DOS drivers. C:\DOS\DRV\Country.sys path and name examples for a file with national specifications data (5.02-01). Note 1: switching between american english and any other national notation doesn't imply changing codepages: american english notation is accessible within any single national codepage (A.02-02). Note 2: switching between different national codepages can be performed by MODE.COM utility too (6.18-03). The latter is usually preferred, because MODE.COM is not a TSR program and releases occupied memory after termination. 5.02-04 KEYB.COM keyboard driver

Control over keyboard layouts is provided by Microsoft's keyboard driver KEYB.COM. Normally it can be found in \WINDOWS\COMMAND directory. The KEYB.COM driver can be loaded directly or with LH command (3.17) from AUTOEXEC.BAT file, or else from CONFIG.SYS file with INSTALL (4.16) or INSTALLHIGH (4.17) command, for example: INSTALL=C:\DOS\DRV\Keyb.com UK,850,C:\DOS\DRV\Keybrd3.sys /E /ID:168 where: C:\DOS\DRV\ path example to KEYB.COM driver, copied into common directory for DOS drivers. UK example of a two-letter national keyboard layout code (other layout codes - in appendix A.02-2 ). 850 example of national codepage number (A.02-2). When it is specified just here, it will not be changed automatically following display codepage change by CHCP command. If synchronous change of codepages (on both display and keyboard) is preferable, then codepage

91

Chapter 5 Selected drivers for MS-DOS7


number here should be omitted, but both enclosing commas must remain intact (. . .UK, ,C:\DOS\DRV\Keybrd3.sys. . .). C:\DOS\DRV\KEYBRD3.SYS path and name examples for keyboard data file. Each such file contains several national layout tables (A.02-2). /E this parameter specifies that keyboard layout should be adapted to "enhanced" 101/108-key keyboard. /ID:168 identifier of a certain keyboard subtype, needed for those countries only, where more than one keyboard layout is used (A.02-2). Most countries, including Russia, use only one keyboard layout, and then the subtype identifier /ID should be omitted. When loaded, KEYB.COM driver activates the following "hot" key combinations: CTRL-RightSHIFT to type symbols 128-255, specific for each selected national codepage; CTRL-LeftSHIFT to type symbols 032-127 (english letters, digits and punctuation symbols), common for all codepages; CTRL-ALT-F1 to activate original american codepage 437 (selected national codepage becomes disabled); CTRL-ALT-F2 to return from american codepage 437 back to selected national codepage; CTRL-ALT-F7 to enable typewriter keyboard mode, if it is supported by the loaded keyboard layout table. All those "hot" keys switchings are accompanied with lousy beep sound, and there is no simple way to get rid of it. Note 1: TSR module of KEYB.COM driver is opened for interaction with programs via INT 2F\AX=AD80h-AD83h (8.03-28, 8.03-30). 5.02-05 KEYRUS.COM combined keyboard and display driver

KEYRUS.COM driver (written by D.Gurtjak, Donetzk) is a combined keyboard and character generator driver. It is popular among russian users, because it is originally supplied with internal 866 (russian) codepage and with russian keyboard layout. But the original release of KEYRUS.COM also contains supplementary programs, which enable the user to write, to install and to activate any codepage and any keyboard layout. The KEYRUS.COM driver can be downloaded for free from many russian internet sites. The last version 8.0b (1994), packed into keyrus8b.zip archive, is available from author's site http://www.gurtjak.skif.net/pages/programs.htm . The KEYRUS.COM driver may be loaded from CONFIG.SYS file with INSTALL (4.15) or INSTALLHIGH (4.16) command, or else from command line or from a line of AUTOEXEC.BAT file - directly or with the LH command (3.17), for example

92

Chapter 5 Selected drivers for MS-DOS7


LH C:\DOS\DRV\Keyrus.com When default settings don't suffice, options should be specified after the driver name in the same command line. As options may be numerous, they can be specified inside a separate file; arbitrary name of this file must be preceded by symbol "@" (at): LH C:\DOS\DRV\Keyrus.com @Opt_file.ext KEYRUS.COM is not loaded and doesn't affect its loaded TSR part when it is executed in command line to show default options: Keyrus /? or to extract internal fonts and keyboard layout: Keyrus /FILES or to change the default specifications. In the latter case the driver name (KEYRUS.COM) must be followed by a group of options, and the last option in this group must be /SAVE. KEYRUS.COM driver consists of three TSR modules: keyboard module, character generator module and interface module. Each module accepts its own set of options. If not specified otherwise, acceptance of option "ON" by KEYRUS.COM instead of option "OFF" (and vice versa) everywhere in examples below is always allowed and leads to reverse results. Options for keyboard module are: /KEYBOARD=Off dont load keyboard module, use BIOS layout. /BASE_KEYS enables key reallocation ( default is OFF). /KEYS=filename.ext take keyboard layout from a file. This file (either 212 or 318 bytes long) may be created by KEYEDIT utility, supplied together with the driver. When KEYRUS.COM is launched with /SAVE option, then specified file is not loaded, but rather becomes KEYRUSs internal default layout. /BUFFER=ON expands keyboards buffer up to 31 characters. /FAST=ON,10,1 set keyboards speed (0 the fastest, then 1, 2, 4, 8, 10, 13, 16, 20, 31 the slowest) and delay from 0 (0,25 s) to 3 (1 s). /RUSALT=ON enables typing symbols [ ] ; ' , . / in any national keyboard layout while the ALT key is kept pressed. /BEEP=OFF,rus no beep at keystroke in RUS (any national) keyboard layout. Instead of RUS the LAT (latin) and ALT (pseudographic) layouts may be specified. /CLICK=OFF,rus no click at keystroke in RUS (any national) keyboard layout. Instead of RUS the LAT (latin) and ALT (pseudographic) layouts may be specified.

93

Chapter 5 Selected drivers for MS-DOS7


/LAMP=ON,rus lit ScrollLock lamp in RUS (any national) keyboard layout. Instead of RUS the LAT (latin) and ALT (pseudographic) layouts may be specified. /COLOR=0,2 indicate keyboard layout with border color. Left color code (0 = black) is for RUS (any national) keyboard layout. Right color code (2 = dark green) is for ALT (pseudographic) keyboard layout. Other allowable color codes in appendix A.10-5. /ALT=87,4 set a "hot" key for switching to pseudographic keyboard layout. Shift 4 and scancode 87 mean switching by CTRL-F11 key combination (see notes 3 and 4 below). /ALT=OFF means no access to pseudographic keyboard layout. /SCAN=54,4 set a "hot" key for switching to RUS (any national) keyboard layout. Shift 4 and scancode 54 mean switching by CTRL-RightSHIFT key combination (see notes 3 and 4 below). /LAT=42,4 set a "hot" key for switching to latin keyboard layout. Shift 4 and scancode 42 mean switching by CTRL-LeftSHIFT key combination (see notes 3 and 4 below). /LAT=OFF means using one "hot" key for toggling to national keyboard layout and back. /MODESHIFT=87,1 set a "hot" key for temporary switching keyboard layouts while this "hot" key is kept pressed. Shift 1 and scancode 87 correspond to RightSHIFT-F11 key combination (see notes 3 and 4 below). /MODESHIFT=OFF disables temporary switching. /CLRSCAN=ON reset all "hot keys" to original defaults. Reconfiguration of "hot" keys requires KEYRUS's interface module to be loaded. The hooked "hot" keys must be chosen so as to be not intercepted later by resident shells or by other TSRs. Character generator's module accepts the following options: /BLANK=ON,9,ON,ON blank screen after, for example, 9 minutes idle, the second "ON" means enabling to feel mouse's movement, the rightmost "ON" means to sense screen output. /SWITCH=22,6 set a "hot" key to switch character generator to DOS's default codepage 437; scancode 22 corresponds to letter "U", shift 6 means keeping pressed both CTRL and LeftSHIFT keys (see notes 3 and 4 below). Switching of codepages doesn't affect keyboard's layout. /SWITCH=OFF means no access to codepage 437. /EGA assume the PC is equipped with EGA-compatible video card. Instead of /EGA you may specify /VGA to assume a VGA-compatible video card. Both /EGA and /VGA options are not saved by /SAVE operation.

94

Chapter 5 Selected drivers for MS-DOS7


/8x8=ON load 8x8 font for 80x43, 80x50 and similar textual videomodes. This option may be set to OFF and AUTO, the latter means loading on software request. /8x14=ON load 8x14 font (used by MS WORD for DOS). This option also may be set to OFF and AUTO, just as the /8x8 option. /8x16=ON load 8x16 font for 80x25 main DOS's videomode 03. This option also may be set to OFF and AUTO, just as the /8x8 option. /FULL load all 3 sorts of internal fonts. /ROM don't load internal fonts, use DOS's default fonts. /FONT=filename.ext load an external font given in a separate file; when used together with /SAVE option, the font is not loaded into memory, but becomes accepted as the default internal font of KEYRUS driver. /DELETEFONT delete the font, which was installed the last. /COMPRESS=OFF don't compress fonts (ON is allowed for textual videomodes only). Choose OFF for graphic videomodes and for "DOS window" of WINDOWS operating system. /ALL load all symbols 0 - 255. Implies no font compression (/COMPRESS=OFF) /128 load symbols 128 - 255. Implies no font compression (/COMPRESS=OFF) /RANGE=128-175,224-239 load symbols within 2 specified ranges, shown as an example. /RUSSIAN load the same ranges as in the example above, but with font compression (/COMPRESS=ON). To switch compression OFF the option /COMPRESS=OFF must be specified explicitly. Interface module of KEYRUS.COM driver accepts the following set of options: /ANYWAY allow to load driver's TSR modules into memory once more. /DELAY_INIT suspend initialization of driver's TSR modules until the KEYRUS.COM driver is launched from command line. /INTERFACE=OFF keep interface module inactive. When it is inactive, programmable reconfiguration is disabled, the KEYRUS.COM driver can't detect presence of its TSR modules in memory and can't unload them from memory. /RELEASE unload TSR modules of the KEYRUS.COM driver from memory. This operation needs the interface module to be active (by default /INTERFACE=ON). Note 1: the KEYRUS.COM driver is not compatible with Microsofts drivers DISPLAY.SYS (5.02-02) and KEYB.COM (5.02-04), as well as with Microsoft's keyboard layout tables KEYB*.SYS (A.02-2). Those files shouldn't be used, if you intend to load KEYRUS.COM driver.

95

Chapter 5 Selected drivers for MS-DOS7


Note 2: resident interface module of the KEYRUS.COM driver interacts with programs via INT 2F\AX=4352h (8.03-24). Note 3: the shift here is a sum of digit 1 for the RightSHIFT key, digit 2 for LeftSHIFT key, digit 4 for CTRL key, digit 8 for ALT key, number 16 for ScrollLock switch, number 32 for NumLock switch, number 64 for CapsLock switch and number 128 for Insert switch (see 8.01-85, the byte returned in AL). For example, shift 12 means holding CTRL and ALT keys while pressing the main "hot" key, defined by its scancode. Note 4: the KEYRUS.COM driver accepts decimal scancodes, so hexadecimal values from the second column in table A.02-1 must be translated into decimal form. Besides this, KEYRUS.COM can't discriminate properly scancodes with and without prefix E0h. Note 5: inside "DOS window" of Windows-95/98 operating systems the KEYRUS.COM driver operates properly only in textual videomodes, that is when this "DOS window" is extended to whole screen with ALT-ENTER keystroke. The "DOS window" of Windows-2000/XP operating systems can be served by KEYRUS.COM driver too, but in this case it must be loaded either from CONFIG.NT file or from AUTOEXEC.NT file, which both are present in \WINDOWS\SYSTEM32 directory.

5.03

Drivers for "mouse" pointing devices

Functions of mouse pointing device become accessible, when four conditions are met. First, you must have a mouse, which is able to perform the desired function(s) and can be connected to your computer. Second, you must load a driver, supporting execution of the desired function(s) by the mouse with appropriate type of connection. Third, the desired functions must be called by the program, which you want to employ these functions. Fourth, both the driver and the program must be able to operate under the operating system, which is installed in your computer. As to the mouse pointing devices, the MS-DOS7 operating system seems inconsistent. On one hand, the Windows-95/98 release provides no mouse driver for MS-DOS7. On the other hand, mouse's functions are needed, for example, for editor utility EDIT.COM (6.09), and mouse drivers from previous versions of DOS operate properly under MS-DOS7. All those mouse drivers for DOS interact with application programs in the same way via interrupt INT 33 (8.03-31 8.03-55). Connection of mouse pointing device to a PC is defined by port address (A.14-1) and by IRQ interrupt request line number. Mouse drivers, described below in part 5.03, are able to search for mouse pointing devices throughout all relevant ports and IRQ numbers. Though connection specification is not necessary, it nevertheless may be given in order to avoid search and make loading faster.

96

Chapter 5 Selected drivers for MS-DOS7


Since new millennium another breed of "mice" has appeared those with USB port connection. Such "mice" rely on pointing device BIOS interface (INT15\AX=C2xx) and on driver's interaction with this interface (5.03-3). In obsolete PCs, where BIOS system doesn't respond to INT15\AX=C2xx calls, necessary support may be provided by a choice of appropriate driver for USB controller (5.07-05), and then any mouse driver, described below in part 5.03, will be able to suffice a mouse, connected via USB port. 5.03-01 GMOUSE.COM mouse driver from KYE Systems Corp.

The GMOUSE.COM driver is supplied in software packets for mouse pointing devices with a well-known trade mark GENIUS, belonging to KYE Systems Corporation. This driver also can be found on compact discs, containing collections of drivers. Version 10.20 of GMOUSE.COM driver (1996) packed into GMOUSE.ZIP archive is available for free downloading from internet site http://www.dosbootsector.narod.ru/drivers.htm . The GMOUSE.COM driver can be loaded either directly or by LH command (3.17) from command line or from AUTOEXEC.BAT file, or else by INSTALL (4.15) or INSTALLHIGH (4.16) command from CONFIG.SYS file, for example: INSTALLHIGH=C:\DOS\DRV\Gmouse.com where: C:\DOS\DRV\ an example of a path to GMOUSE.COM driver. Normally the GMOUSE.COM driver doesn't needs parameter specifications, but nevertheless it can accept any one of the following mutually excludible parameters: /1 mouse connection via serial port COM1 /2 mouse connection via serial port COM2 /3 mouse connection via serial port COM3 /4 mouse connection via serial port COM4 /P mouse connection via PS2 Port. /P2 2-button mouse, connected via PS2 port. /P3 3-button mouse, connected via PS2 port. /U unload GMOUSE.COM driver from memory. /? display short help. The listed parameters are also suitable for newer versions of GMOUSE.COM driver, which have increased file size and several superfluous functions, such as automatic determination of language for messages on basis of the loaded codepage. Contrary to newer versions, version 10.20 of GMOUSE.COM driver can accept some more parameters from a special parameter file GMOUSE.INI, if it is present in the same directory with the driver. Note 1: if during loading a search for mouse pointing device is stopped by BREAK keystroke, for example, in order to read the displayed messages, then after any

97

Chapter 5 Selected drivers for MS-DOS7


other keystroke the GMOUSE.COM driver is unable to resume the search, and PC gets hanged. Note 2: when mouse pointing device is connected to port COM3 or COM4, the GMOUSE.COM driver doesn't provide compatibility with Windows OS.

5.03-02

MOUSE.COM "mouse" driver from Microsoft Corp.

The MOUSE.COM name was common for several mouse drivers, written at different times by different authors. Here the version 8.20 is described of Microsoft's MOUSE.COM driver (file size 37681 bytes, file date 29.06.93). It was supplied within MS-DOS6.22 release, but was found compatible with MS-DOS7 too. Archive MOUSE.ZIP containing MOUSE.COM driver can be downloaded from internet site http://www.computerhope.com/download/hardware.htm#05 . The MOUSE.COM driver may be installed either from CONFIG.SYS file with INSTALL (4.15) or INSTALLHIGH (4.16) command, or else directly or with LH command (3.17) from AUTOEXEC.BAT file or later from command line: C:\DOS\DRV\Mouse.com /C1 /R1 /S50 /P2 /N50 /Y where: C:\DOS\DRV\ an example of a path to MOUSE.COM driver. /C1 select COM1 port. Instead of /C1 there may be: /C2 for mouse connected to COM2 port; /Z for mouse connected to PS2 port; /I1 for mouse on LPT1 port; /I2 for mouse on LPT2 port; /B for bus mouse. /R1 specifies interrupt rate 30 Hz (the default). Alternatives are: /R2 interrupt rate 50 Hz, /R3 interrupt rate 100 Hz, /R4 interrupt rate 200 Hz. /S50 specifies sensitivity; the number after /S is allowed within range 0 - 100, 50 is the default. Instead of /S50 there may be separate /H50 horizontal and /V50 vertical sensitivity specifications. /P2 slow acceleration profile number. Alternatives are: P1 profile without acceleration P3 moderate acceleration profile; P4 fast acceleration profile. /N50 number after /N specifies cursor redraw rate (0 255 is allowed). /Y use hardware cursor feature.

98

Chapter 5 Selected drivers for MS-DOS7


In most cases all optional specifications are not needed, since the default values are sufficient, and the driver is able to search for mouse pointing devices throughout all relevant ports. In order to disable mouse you may unload this driver by launching it with single OFF parameter: C:\DOS\DRV\Mouse.com OFF 5.03-03 CTMOUSE.EXE freeware "mouse" driver

The CTMOUSE.EXE driver is developed since 2002 as a part of FreeDOS project, but it is made compatible with MS-DOS7. Version 2.1 of CTMOUSE.EXE (dated 2007), packed in archive CTMOUS21.ZIP, may be downloaded from internet site .Another address, http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/mouse/ where recent versions of this driver can be found, is http://cutemouse.sourceforge.net/ . Functionally CTMOUSE.EXE is similar to other mouse drivers for DOS, but it occupies less memory and supports pointing devices equipped with a wheel. One more important feature of this driver is its interaction with pointing device BIOS interface (INT15\AX=C2xx). Therefore it provides better chances to suffice USB mice in modern PCs. CTMOUSE.EXE driver has an elaborated set of defaults, which make command line parameters in most cases unnecessary. It may be loaded either from command line or from AUTOEXEC.BAT file directly or by LH command (3.17), or else from CONFIG.SYS file by INSTALL (4.15) or INSTALLHIGH (4.16) command, for example: INSTALL=\DOS\DRV\Ctmouse.exe /S14 /3 /R33 /N where: \DOS\DRV\ path example to Ctmouse.exe driver. /S14 search for mouse pointing device through serial ports only. The first digit denotes serial port number (=COM1), the second interrupt request line number (=IRQ 4). If the /S parameter is not specified, driver will examine PS2 port first, and then all serial ports. /3 activate mouse's third button. This function can't be applied to mice of Mouse System type and to mice with a wheel instead of middle button. /R33 sensitivity settings: first digit is a grade of horizontal sensitivity, second digit of vertical sensitivity. If only one digit is specified, it is applied to both coordinates. Default /R parameter value is /R33. /N load Ctmouse.exe driver even if some mouse driver has been loaded yet. This parameter enables to compose batch files so that after unloading of Ctmouse.exe driver the configuration returns back to its original state, whichever this state was. Besides the shown parameters, Ctmouse.exe driver can accept the following options:

99

Chapter 5 Selected drivers for MS-DOS7


/? /P /Y /V /O /L /B /W /U display a short help; examine the PS2 port only; dont search for "mouse" of Mouse System type; reverse search order: examine serial ports first; disable mouse wheel detection; adapt buttons order for left-handed people; dont load Ctmouse.exe, if some mouse driver is loaded yet; load Ctmouse.exe into conventional memory; unload CTMOUSE.EXE driver from memory (this can't be done if functions of the driver are intercepted).

5.04

Memory managers

In AT-compatible computers the 640 1024 kb memory region is hardware consigned for special usage as BIOS code "shadow", as a "window" into video memory, as a page frame "window", etc. (see notes 2 and 3 to A.12-1 for more details). Because of 16-bit addressing and because of special status of 640 1024 kb memory region the accessible memory space for DOS programs is considerably limited. Since early 1980-ties researchers in all leading software companies attempted to overcome memory space restrictions. Nowadays these attempts are continued by many independent software vendors. The best solutions of this problem are presented here in the following articles. 5.04-01 HIMEM.SYS extended memory driver

HIMEM.SYS is Microsoft's memory driver for PCs with CPU 80386 or higher, providing machine-dependent access to memory beyond the 1024 kb boundary according to eXtended Memory Specification (XMS). Therefore the memory, opened by HIMEM.SYS, is often called XMS memory. Since version 3.10 of HIMEM.SYS driver the upper limit of XMS memory is 65535 kb. Besides access to XMS memory, the HIMEM.SYS driver performs two important functions: control over switching of A20 line gate and allocation of memory space, requested by different programs. Both these functions are necessary in order to prevent conflicts between programs, addressing memory beyond conventional memory limit (640 kb). Due to HIMEM.SYS driver each program, requesting some space in UMB region or in XMS memory, is given exclusive access rights to the allocated part of memory space. Official explanations of HIMEM's operation principle are not known, but analysis of its code gives some grounds to suppose, that it uses 32-bit linear addressing in real mode (more about that in 9.10). In any case, HIMEM's operation principle gives no chance to execute programs in XMS memory, it gives only an opportunity to copy executable code together with data from conventional memory into XMS memory and back.

100

Chapter 5 Selected drivers for MS-DOS7


Version 3.95 of HIMEM.SYS driver (1995) is supplied in WINDOWS-95/98 release and normally may be found in \WINDOWS directory. The HIMEM.SYS driver should be loaded with DEVICE command (4.06) preferably in the first executable line of CONFIG.SYS file, for example: DEVICE=C:\DOS\DRV\Himem.sys /V where: C:\DOS\DRV\ path example to HIMEM.SYS driver; /V display loading information. The same may be achieved if the ALT key is kept pressed while HIMEM.SYS is being loaded. HIMEM.SYS has internal default settings, which are suitable for a wide variety of PC's hardware. In rare cases you may have to specify other settings by optional parameters. Allowable optional parameters are: /a20control:OFF allows HIMEM.SYS to take control over A20 bus if it is not active only, thus preventing A20 bus interruptions (default is to take control always). /cpuclock:ON activate CPU clock frequency control, when this frequency becomes affected by upper memory access. This parameter makes HIMEM.SYS work slower. /eisa provides access beyond 16 Mb on PCs with EISA bus. /hmamin=40 prevents reserving of HMA area (1024 1088 kb) to any program demanding less than 40 kb (range is 0 63 kb). By default HMA area is allocated to the first program that requests it, regardless of how much of HMA space the program intends to use. /int15=128 reserve 128 kb (range 64 65535, default is 0) for programs, accessing memory via interrupt INT 15\AH=87h (8.01-76). /machine:AT specification of PC types, which HIMEM.SYS can't identify properly, by number (from 1 to 17) or by literal identifier (see table A.11-2). Default is number 1 or identifier AT (both correspond to IBM's PC/AT). /noabove16 don't use INT 15\AX=E801h (Compaq Bigmem support) to scan for memory beyond 16 Mb. In this case HIMEM.SYS can't provide XMS access beyond 16 Mb. /noeisa prohibit search for memory extension cards on EISA bus. /numhandles=32 maximum number of active references (handles) to XMS memory blocks, which can be kept open simultaneously; allowed range is from 1 to 128, 32 is the default. /shadowRAM:ON don't prevent BIOS to RAM transfer into segment address space F000 - FFFFh. When HIMEM.SYS detects RAM size 2 Mb or less, it tries to prevent BIOS to RAM transfer in order to get more memory free. /testmem:OFF bypass XMS memory test.

101

Chapter 5 Selected drivers for MS-DOS7


/X don't explore memory with INT 15\AX=E820h (8.01-80).

Note 1: HIMEM.SYS driver gives no access to memory beyond 16 Mb, if CMOS BIOS parameter "Memory hole 15 16 Mb" is enabled. Note 2: HIMEM.SYS driver accepts program's requests via CALL FAR commands (7.03-08). Address for CALL FAR commands can be obtained with INT 2F\AX=4310h function (8.03-23). A list of operations, which can be requested by programs, is shown in table A.12-3. Note 3: several similar XMS memory drivers have been developed by different authors. J.R.Ellis wrote QHIMEM2.SYS driver, which extends XMS memory limit to 4 Gb. Version 3.1 of this driver (dated 2005) is available inside SFX diskette image USB18.EXE from site http://johnson.tmfc.net/dos/usbdrv.html . The most recent 4 Gb XMS memory driver XMGR.SYS can be downloaded from page http://johnson.tmfc.net/dos/driver.html . One more similar driver Himem.exe is developed as a part of FreeDOS project and is supplied together with Emm386.exe (see note 4 to 5.04-02). Alternative XMS memory drivers accept different sets of options, described in attached files. Note 4: in MS-DOS8 the XMS access code is integrated into the core, hence there is no need to load Himem.sys. 5.04-02 EMM386.EXE memory mapping driver and VCPI server.

EMM drivers (EMM = Expanded Memory Manager) originally were developed in 1983 1984 in order to provide access to memory banks on expansion cards for IBM PC, so that any memory bank can be addressed through the same "window" in address space (usually in segment addresses E000 EFFFh). This method of addressing memory banks was institutionalized by LIM EMS specification. Among other details, LIM EMS specification stipulates division of the address space "window" into several pages of 16 kb each, which independently direct addressing to different memory banks. Later the main computer's memory has grown far above 1 Mb, and expansion cards with memory banks have come out of use. But some popular programs still relied on old-fashioned LIM EMS access, and compatibility with these programs had to be preserved. Therefore the fundamental principle of EMM driver's operation has been changed: control over expansion cards has been replaced by control over address translation mechanism, which is embedded in all CPU's since 80386. This is why such memory managers are named EMM386. They enable to address the main computer's memory above 1 Mb through the same LIM EMS "window" in address space. Here is just a place to remind, that main computer's memory above 1 Mb is controlled by XMS driver HIMEM.SYS (5.04-01), and memory space allocation according to program's requests is just its prerogative. Hence the EMM386 driver plays a role of an intermediary transactor: having got a program's request for LIM EMS access to a memory

102

Chapter 5 Selected drivers for MS-DOS7


space, it asks the HIMEM.SYS driver and gets a suitable piece of memory beyond 1 Mb. Then EMM386 rewrites data in CPU's TLB table so that the caller program becomes able to access the allocated piece of memory via the LIM EMS "window" in address space. When there is no a single piece of requested size, the EMM386 driver combines several pieces of smaller size. Due to address translation in CPU, the LIM EMS "window" in address space enables not only access, but execution of programs too. Mission of EMM386 driver is complicated by the fact that address translation mechanism is activated only when CPU works in protected mode. Therefore the EMM386 driver switches CPU into virtual 8086 (V86) mode, which is a variant of protected mode, and then all DOS programs are executed in this mode at the third (the lowest) privilege level. Of course, PC must have a CPU of 80386 type or newer, which is able to implement V86 mode. EMM386 driver gives to DOS programs a permission for I/O operations at the lowest privilege level, so that conditions of access to disks and to ports are the same as in real mode. Additional features, inherent to the V86 mode, are used by EMM386 driver for loading other drivers "through" free areas of UMB address space (640 1024 kb) and for control over attempts of other programs to affect implementation of protected mode. At least three types of programs pretend to control protected mode implementation in DOS. These are extender programs (for example, DOS4GW.EXE), DPMI servers (for example, CSWDPMI.EXE), and loaders of operating systems (for example, the Windows' GUI loader WIN.COM). Such contenders can't perform their mission in V86 mode at the lowest privilege level. In order to enable smooth control transfer to such programs the VCPI protocol (VCPI = Virtual Control Program Interface) has been adopted in 1989. It was developed jointly by Phar Lap Software and Quarterdeck Office Systems. According to VCPI protocol, the program, which switches CPU into V86 mode, must perform several extra functions on request, including transition to the highest privilege level. Since EMM386 implements these extra functions, it is also called VCPI server. Some of VCPI server's functions are described in articles 8.03-71 - 8.03-73. Direct execution of programs beyond 1088 kb boundary is necessary for loading drivers there, but that's not enough. Ordinary driver's code is not adapted to page-by-page addressing. Therefore for loading drivers the EMM386 manager arranges static mapping of memory beyond 1088 kb onto UMB blocks, which can be squeezed in all free stretches of address space between 640 and 1024 kb. If EMM386 memory manager is loaded yet, and then is launched from command line once more (without parameters), it will show on the screen the exact allocation of entrusted address space. Windows-95/98 release includes version 4.95 of EMM386.EXE driver (date 6/12/1996, size 125495 bytes). This version is not intended, though, for service to a separate operating system MS-DOS7. Version 4.95 transfers exception calls to protected mode handlers, installed by Windows OS. But when MS-DOS7 runs alone, exception calls don't find their handlers, and PC gets hanged. This is why earlier versions 4.49 or 4.50 of EMM386.EXE driver are more suitable for MS-DOS7. These versions are loaded in the

103

Chapter 5 Selected drivers for MS-DOS7


same way and accept the same set of options. Version 4.49 (date 31/05/1993, size 120926 bytes) can be downloaded from server ftp://ftp.vgt.ru/dos/ inside diskette image Dos622_1.img, which can be written to diskette by IMG.EXE (6.06). Then file EMM386.EX_ should be unpacked by EXPAND.EXE (6.10). Version 4.50 (date 30/04/1998, size 119390 bytes) from IBM's PC DOS 2000 release can be downloaded inside SFX archive Pcdos2k.exe from server ftp://ftp.eesnet.ru/dos/ . Loading of DOS structures and of other drivers beyond conventional memory by LH (3.17), DEVICEHIGH (4.07) and other commands, ending with ...HIGH, requires memory manager to be loaded yet. But access beyond conventional memory must be provided in advance, before the EMM386.EXE driver is loaded. Therefore EMM386.EXE driver should be loaded by DEVICE command (4.06) from that line of CONFIG.SYS file, which follows HIMEM.SYS (5.04-01) loading line, but precedes to all lines with commands, having the ...HIGH ending. A line loading EMM386.EXE driver may look, for example, as DEVICE=C:\DOS\DRV\Emm386.exe RAM V where: C:\DOS\DRV\ path example to EMM386.EXE driver; RAM allow arrangement of EMS pages and UMB blocks (another form of RAM parameter usage is shown further); V display allocation of EMS pages and UMB blocks. Besides the shown options, EMM386.EXE driver can accept optional parameters from the following list: OFF suspend activation of EMM386.EXE until command "EMM386.EXE ON" is launched from command line. Parameter AUTO (instead of OFF) also allows activation on software request. While EMM386.EXE is not active, it doesn't support loading beyond conventional memory by LH command and by all other commands ending with "HIGH". 8196 an example of requested EMS-memory size in kb, from 16 kb up to actual size of free XMS-memory (latter is the default), but not more than 32768 kb. If NOEMS switch is specified (see further), the default value is set to zero. EMM386 rounds any requested value down to the nearest multiple of 16 kb. min=256 don't establish EMS-memory, if its available amount doesn't exceed this minimum value, ranging from 0 up to requested memory size, 256 kb is the default (unless the NOEMS switch is specified). W=ON enable Weitek coprocessor support (default is OFF). When EMM386 is active, it accepts from command line commands EMM386 W=OFF EMM386 W=ON

104

Chapter 5 Selected drivers for MS-DOS7


M4 an example of start segment address specification for page frame placement. Page frame is a region for successive continuous placement of EMS pages 0 3 (16 kb each). The number after "M" is a code (from 1 to 14), which denotes segment addresses 1 = C000h, 2 = C400h, 3 = C800h, 4 = CC00h, 5 = D000h, 6 = D400h, 7 = D800h, 8 = DC00h, 9 = E000h (the default setting), 10 = 8000h, 11 = 8400h, 12 = 8800h, 13 = 8C00h, 14 = 9000h FRAME=CC00 an example of direct specification for the same page frame start address. Other start addresses, except those shown above, are not allowed. In order to prohibit frame page you may specify FRAME=NONE, and this will be equivalent to the NOEMS parameter (see further). /PCC00 one more example of another form for the same page frame start address specification; the same 14 values can be specified after the /P parameter. P4=DC00 an example of specification for adding one more EMS page P4 (the fifth) to the page frame CCOOh DBFFh. There may be several "P" parameters for EMS pages denoted by numbers from 4 to 14. When page frame start address is not specified otherwise, numbers 0 3 are allowed too, but sequential continuous allocation of EMS pages 0 3 must be preserved. X=F000-FFFF a specification example for a prohibited region of segment addresses (within A000h FFFFh range), which must be left intact. Specified segment addresses will be rounded down to the nearest 4-kilobyte multiple. I=BC00-BFFF a specification example for a region of segment addresses to be allocated for UMB blocks. Specified segment addresses will be rounded down to the nearest 4-kilobyte multiple. When "I" and "X" specifications overlap, the "X" option takes preference. B=4000 lowest boundary segment address (within range 1000h 4000h) of allowed EMS pages placement region. Default lowest boundary is 4000h. L=256 size of memory space (in kb) reserved for XMS-type access (default is 0 kb). A=7 number of register banks to provide support for multitasking (0 254 allowed, default is 7). Each register bank takes about 200 bytes. h=64 number of references (handles) to EMS memory areas, which can be kept open for access simultaneously (2 255 allowed, default is 64). d=32 size of reserved Direct Memory Access (DMA) buffer (16 256 kb allowed, default is 32 kb).

105

Chapter 5 Selected drivers for MS-DOS7


RAM=C000-EFFF a specification example of region boundaries for UMBs and EMS pages placement. When "RAM" parameter is not followed by boundary segment addresses, all available memory space is regarded as allowable. WIN=E000-EFFF an example of segment addresses, specifying boundaries of address space region, reserved for being used by Windows OS. ROM=F000-FFFF load BIOS shadow into a part of address space, specified by segment addresses of its boundaries, if this is not done by PCs BIOS itself. Copying of BIOS code can make your PC more fast. NOEMS don't create EMS page frame, don't provide LIM EMS memory access, but use all available address space in 640 1024 kb region for arranging UMBs and for loading drivers. NOHI load the whole resident module of EMM386.EXE driver into conventional memory below 640 kb. NOMOVEXBDA cancel default loading of BIOS shadow. NOTR exclude network card search (for EMM386.EXE versions 4.45 4.95) NOVCPI disable support for VCPI functions (see note 2 below), requested by other programs. This switch should be used together with the NOEMS switch. HIGHSCAN launch a thorough search for free stretches of address space, thus making its usage more efficient. But there is a chance to consider engaged space as free, and then your PC may get hanged. ALTBOOT replace hot reboot handler (only if CTRL-ALT-DEL "hot key" combination stops responding or goes wrong after loading of EMM386.EXE driver). NOBACKFILL prevent conventional memory from being backfilled, when EMM386 attempts to create UMBs in a PC having total memory 640 kb or less. When the EMM386.EXE driver is loaded yet and active, it can accept commands "EMM386 OFF" and "EMM386 AUTO" from command line. But these commands will not be executed, if at that moment UMB address space has been used already for loading other drivers, which must remain available for DOS. Note 1: the EMM386.EXE driver accepts requests from other programs via INT 67 (8.03-57 8.03-74). Note 2: VCPI services, provided via INT 67\AX=DE00h-DE0Ch, give a chance to perform their mission for programs, which have to affect V86 mode of CPU operation, set by EMM386.EXE. Due to VCPI services, in particular, the Windows OS can be loaded even if the V86 mode is set yet. But the Windows OS itself inside its "DOS window" disables VCPI services, thus excluding risk to lose control over the PC.

106

Chapter 5 Selected drivers for MS-DOS7


Note 3: a version of EMM386.EXE from MS-DOS8 is not compatible with some model types of obsolete 486 processor and may cause hanging. Note 4: several similar EMM386 managers are known to be developed. The most advanced is JEMM386.EXE driver, written by a group of authors under auspices of Tom Ehlert. Now, in december 2007, archive JEMM568.ZIP with version 5.68 of this driver can be downloaded from internet site http://japheth.de/ . One more version of EMM386.EXE driver is developed as a part of FreeDOS project; it can be downloaded from server ftp://ftp.devoresoftware.com/downloads/ . Both mentioned drivers are more compact, than original EMM386.EXE, and accept different sets of options, described in attached files. 5.04-03 Memory allocation optimization: CHKSTATE.SYS

CHKSTATE.SYS is a special service utility for memory optimization procedure, developed for MS-DOS6, but proved to be suitable in MS-DOS7. A line loading CHKSTATE.SYS is inserted into CONFIG.SYS file automatically by memory optimization manager MEMMAKER.EXE, and is deleted in the same way when memory optimization procedure terminates. Being executed, CHKSTATE.SYS utility forms a textual report file, containing exact data about memory areas, allocated for each loaded driver. Note 1: for performing memory optimization procedure the main optimization manager MEMMAKER.EXE must be in one directory with auxiliary files CHKSTATE.SYS, EMM386.EXE, HIMEM.SYS, MEMMAKER.HLP, MEMMAKER.INF and SIZER.EXE. All these files are present in MS-DOS6.22 release, and also are contained in SFX archive OLDDOS.EXE, freely available from server ftp://ftp.microsoft.com/softlib/mslfiles/ . Note 2: the MEMMAKER.EXE optimizer is unable to make proper corrections in AUTOEXEC.BAT file and in CONFIG.SYS file, if the latter contains a menu with several loading alternatives. Each alternative variant should be optimized separately. Nevertheless the data, obtained for each loading alternative separately, enable to compose optimized configuration files with several loading alternatives. 5.04-04 UMBPCI.SYS freeware UMB region driver

In order to open UMB address space (C000h EFFFh) for loading drivers, the EMM386.EXE memory manager (5.04-02) arranges address translation via CPU's TLB tables and forces to pay for that with switching CPU into V86 mode. But when it is necessary to stay in real mode, access to UMB address space may be opened by reprogramming memory controller, which is a part of chipset on PC's motherboard. This alternative way of access to UMB address space is implemented by UMBPCI.SYS driver.

107

Chapter 5 Selected drivers for MS-DOS7


The UMBPCI.SYS driver has a long development history with a lot of participants. Now it is continued by Uwe Sieber. The most recent version of UMBPCI.SYS can be found in internet site http://www.uwe-sieber.de/ , packed in archive UMBPCI.ZIP with attached texts in german, or else in archive UMBPCI_E.ZIP with attached texts in english. The description below is based on version 3.66 of UMBPCI.SYS, dated march 2006. By no means, UMBPCI.SYS is not a replacement of EMM386.EXE, it does not implement LIM EMS specification. UMBPCI.SYS performs only functions, stipulated by XMS specification, but just those, which are incumbent upon EMM386.EXE driver (see note 6 to A.12-3). In order to affect memory controller's settings, the UMBPCI.SYS driver calls BIOS's interrupt handlers INT 1A\AH=B1h, related to PCI bus services. This is why the UMBPCI.SYS driver can perform its mission only in computers, which are equipped with PCI bus, controlled by PC's BIOS. These conditions are met by almost all AT-compatible computers, produced after 1996. One exception is represented by computers with AMD-K7 processor: in such computers the UMB blocks, created by UMBPCI.SYS driver, can't be used for loading those drivers, which control expansion cards on PCI bus. The UMBPCI driver provides access to free parts of "shadow" memory area, intended for copying executable codes from slow fixed storage BIOS chips. Not every chipset is able to provide direct memory access (DMA) into this "shadow" memory region. The DMA access is necessary for floppy disks controller, for SMARTDRV.EXE driver (5.0601), and even for the WINDOWS OS, if it would be loaded later. The archives with UMBPCI.SYS driver contain some auxiliary utilities, enabling to avoid undesirable consequences of restrictions on DMA access to "shadow" memory areas. In the same archives there are files with advices, helping to overcome problems, specific for some particular chipsets. Of course, relevant peculiarities must be taken into account. The UMBPCI.SYS driver should be loaded by DEVICE command (4.06) from that line of CONFIG.SYS file, which follows loading of HIMEM.SYS driver (5.04-01) and precedes all lines with commands LH and those having the ...HIGH ending. The line loading UMBPCI.SYS driver may look, for example, as DEVICE=\DOS\DRV\Umbpci.sys /I=D000DFFF where \DOS\DRV\ path example to UMBPCI.SYS driver. /I=D000DFFF an optional specification of segment address space, which should be allocated for UMB blocks. Boundaries of the allocated space must be multiples of 16 kb (that is C800, CC00, D000, D400, D800 and so on). If the /I= parameter is specified, then UMBPCI.SYS will not examine address space areas on whether they are free or not. Presence of several /I= parameters in one command line is allowed, and then each UMB area will be given a serial number. The

108

Chapter 5 Selected drivers for MS-DOS7


DEVICEHIGH (4.07) and LH (3.17) commands accept serial number of UMB area after their /L: parameter, and due to that there is an opportunity to load any particular driver through the prescribed part of UMB address space. The latter is important for those drivers, which use direct memory access (DMA), because some chipsets for example, i430TX provide DMA access only inside the E000 EFFFh part of UMB region. Most often the /I= parameter is not needed, since popular modern chipsets (i815, i820, i845, i850, i855 and many others) apply no restrictions on DMA access to UMB region. Note 1: in obsolete computers, having no PCI bus, access to UMB address region may be provided by HIRAM.EXE driver (written in 1993) and its auxiliary utilities. This set of software can be downloaded as one archive from internet site http://www.uwe-sieber.de/files/hiram.zip .

5.05

RAM-disk drivers

RAM-disk drivers occupy a part of computer's random access memory (RAM) in order to simulate a virtual disk drive. This provides access to writable disk space during exploratory and reparatory works, when physical disk space may not exist or must be preserved free from traces of access. Virtual RAM-disks are much faster, than any physical disk. Since contents of RAM-disk is lost each time the PC is switched off, RAMdisks sometimes are used as a place for temporary files in order to avoid pollution of physical disk space. A common drawback of many RAM-disk drivers is that they are unable to assign a certain letter-name for the created virtual disk. DOS always assigns to virtual disk the first free letter-name, which cant be known beforehand. One solution, presented in article 9.04-02, is a search for a particular letter-name, assigned to the arranged virtual disk. Another solution is to write a special driver, which will deceive DOS with a false number of registered disks, so that the next disk could be given an arbitrary prescribed letter-name. An example of the latter solution is presented in article 9.08. 5.05-01 RAM-disk driver RAMDRIVE.SYS

RAMDRIVE.SYS is Microsoft's RAM-disk driver for DOS, supplied within WINDOWS-95/98/ME releases. Normally it can be found in \WINDOWS directory. RAMDRIVE.SYS should be loaded by a DEVICE (4.06) or DEVICEHIGH (4.07) command from a line of CONFIG.SYS file, for example: DEVICE=C:\DOS\DRV\Ramdrive.sys 16000 512 256 /E where: C:\DOS\DRV\ a path example to RAMDRIVE.SYS driver.

109

Chapter 5 Selected drivers for MS-DOS7


16000 512 256 /E an example of requested RAM-disk size in kilobytes, 4 32767 kb range is allowed, 64 kb is the default value. an example of sector size in bytes; 128, 256 and 512 bytes are allowed, 512 is the default value. If sector size is specified, RAM-disk size must be specified too. an example specification of entries number in the root directory of RAM-disk, 2 1024 are allowed, 64 is the default value. If number of entries is specified, sector size must be specified too. optional parameter, forcing to arrange RAM-disk in XMS memory, provided by HIMEM.SYS driver. Instead of /E you may specify /A parameter, forcing to use EMS memory access, provided by EMM386.EXE driver.

You may set up as many RAM-disks as free memory space allows: just add one such line to your CONFIG.SYS file per each extra RAM-disk. Note 1: RAM-disk driver RDISK.COM with 2 Gb size limit may be downloaded from http://johnson.tmfc.net/dos/driver.html . This driver should be used together with XMS memory managers providing 4Gb XMS memory limit (note 3 to 5.04-01). 5.05-02 Reconfigurable drivers TDSK.EXE and BITDISK.EXE

Freeware drivers TDSK.EXE and BITDISK.EXE enable to define RAM-disk size not only at the moment of loading, as RAMDRIVE.SYS driver does, but also enable to postpone RAM-disk size definition, and even enable to do it repeatedly. This feature is very important for installation of MS-DOS7 on an unknown computer, because you need to determine available amount of memory before a decision can be made about whether to arrange a RAM-disk and of what size. Both TDSK.EXE and BITDISK.EXE drivers were written by Garcia de Celis, Valladolid, Spain, in 1992 1995, and then the last was version 2.3. Later these drivers were modernized and became a part of FreeDOS project. Now both these drivers can be downloaded from http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/ramdisk/ . Original drivers of Garcia de Celis are there in archive TDSK23.ZIP, and modernized version 2.42 of the TDSK.EXE driver in archive TDSK242B.ZIP. BITDISK.EXE is a simplified version of TDSK.EXE. While the latter is able to employ EMS, XMS or conventional memory, BITDISK.EXE can cope with XMS memory only. Therefore it always needs the HIMEM.SYS driver to be loaded in advance. TDSK.EXE can accept all BITDISK's options and, besides that, some options of its own. Original drivers of Garcia de Celis should be initialized by DEVICE (4.06) or DEVICEHIGH (4.07) command in a line of CONFIG.SYS file. Modernized version 2.42 of the TDSK.EXE driver must be loaded in conventional memory only by DEVICE

110

Chapter 5 Selected drivers for MS-DOS7


command (4.06), provided that CONFIG.SYS file also contains a line with DOS=NOAUTO command (4.08). RAM-disk initialization line may include all required parameters (see further), and then RAM-disk will be created at once. But when creation of RAM-disk should be retarded, command line in CONFIG.SYS file must not include particular parameter's values; it may look, for example, as DEVICEHIGH=C:\DOS\DRV\Bitdisk.exe 0 or else as: DEVICE=C:\DOS\DRV\Tdsk.exe 0 where: C:\DOS\DRV\ path example to the driver; 0 zero size denotes that RAM-disk shouldn't be arranged at once. The shown command doesn't cause memory allocation for the RAM-disk, but induces loading and initialization of driver's TSR module (about 600 bytes). At this stage DOS registers new RAM-disk and assigns its letter-name. If you repeat this line in CONFIG.SYS file more than once, you can initialize several RAM-disks. In order to make RAM-disk accessible, the same driver must be invoked later by a command, written into a line of AUTOEXEC.BAT file or directly into DOS' command line, for example: C:\DOS\DRV\Bitdisk.exe R: 5600 512 384 4 /F:2 or else C:\DOS\DRV\Tdsk.exe R: 5600 512 384 4 /F:2 /E /M /I=1 where: R: 5600 letter-name of the addressed RAM-disk, if there are several RAMdisks. Letter-name of a single RAM-disk may be omitted. an example of required disk's size specification (in kb). Minimum size is 4 kb, maximum 32766 kb for BITDISK.EXE and 65534 kb for TDSK.EXE. Command with size 0 releases all occupied memory, except that for driver's TSR module: it remains loaded and ready to rearrange RAM-disk on request. optional specification example for sector size (in bytes); sector sizes 64, 128, 256 and 512 bytes are allowed, the latter is the default. optional number of entries in the root directory. Allowed values are from 1 to disk size limit, 384 is the default. When number of entries isn't omitted, sector size must be specified too. optional number of sectors per cluster, in MS-DOS7 must be a power of 2. Default is the minimum number corresponding to RAM-disk's size. When number of sectors per cluster isn't omitted, then number of entries in the root directory must be specified too.

512 384 4

111

Chapter 5 Selected drivers for MS-DOS7


/F:2 specifies creation of TWO copies of FAT, as in real disks (default is creation of a single FAT table). In rare cases some disk addressing utilities can't work properly with virtual disks, having only one FAT.

Command line, addressed to TDSK.EXE, contains some additional options, accepted by TDSK.EXE only. Allowable additional options for version 2.42 of TDSK.EXE driver are: /E arrange RAM-disk in XMS memory (the default), provided by HIMEM.SYS driver, which has to be loaded yet. /C arrange RAM-disk in conventional memory. /X (or equivalently /A) arrange RAM-disk in EMS memory, provided by EMM386.EXE driver. In this case both EMM386.EXE and HIMEM.SYS memory drivers must be loaded in advance. /B don't load TDSK.EXE driver, if at least one real disk drive is found (this option isn't accepted by original version 2.3 of TDSK.EXE driver). /M display screen messages in monochrome (default is color). /I=1 display messages in english (the default); besides this, spanish (/I=34) and german (/I=49) languages may be chosen. Auxiliary options /E, /C, /X, /A are mutually exclusive and usually are omitted, because TDSK.EXE driver itself is able to choose optimum place to arrange RAM-disk. The shown form of command can be repeatedly used to call either TDSK.EXE or BITDISK.EXE in order to change RAM-disk's size. Each time after this command RAMdisk is rearranged anew, and all its contents becomes lost. RAM-disk data are not affected by either driver in two cases: if it is called without parameters to show current status; if it is called with a single /? parameter to show help. In order to solve the problem of RAM-disk letter-name determination, version 2.42 of TDSK.EXE driver is able to assign this letter-name as a value to environmental variable named TURBODSK or RAMDRIVE. An environmental variable with any of the mentioned names should be prepared in advance with SET command (3.26), and it should be given a question mark and a colon as its preliminary value: SET RAMDRIVE=?: If a variable with the same name has another value, it will be preserved intact. But if this variable has just the shown value, and if at that moment RAM-disk is arranged already, then after execution of TDSK.EXE driver the question mark in variable's value will be replaced by letter-name of the RAM-disk. When RAM-disks letter-name is known yet, then it's easy to compose AUTOEXEC.BAT file so that this letter-name is automatically written into all relevant paths (an example in article 9.09-02).

112

Chapter 5 Selected drivers for MS-DOS7


After execution the TDSK.EXE driver returns errorlevel code (3.15-03, 9.07-03). Errorlevel values from 1 to 128 denote a reference number (handle) for XMS or EMS access to allocated memory area; other errorlevel values mean the following: 0 RAM-disk is not arranged since it isn't defined; 252 syntax error; 253 attempt to define a RAM-disk under Windows OS; 254 incorrect specification of disks letter-name; 255 TSR module of TDSK.EXE driver is not loaded.

5.06
5.06-01

HDD services
SMARTDRV.EXE cache buffer driver

The SMARTDRV.EXE driver arranges and maintains disk's cache buffer. Data transfer operations in this buffer are performed via DMA controller. DMA access gives some relief to CPU and makes transfer operations faster for both HDDs and CD drives. Time saving effect becomes essential in case of large data amounts transfer, for example, during installation of operating systems Windows ME/2000/XP under DOS. The SMARTDRV.EXE driver is a part of Windows-95/98 release and must be present in \WINDOWS directory. But WINDOWS OS itself performs buffering otherwise and doesn't need SMARTDRV.EXE. It is needed only in DOS, and in MS-DOS7 as well. Since the cache buffer is expedient beyond conventional memory, access above 640 kb must be opened in advance. Therefore appropriate memory manager(s) (5.04-01, 5.04-02, 5.04-04) must be loaded before SMARTDRV.EXE. If you intend to access CD-ROMs with MSCDEX.EXE (5.08-03), the latter also should be loaded in advance. Most often SMARTDRV.EXE is loaded either by INSTALL command (4.15) from CONFIG.SYS file or from a line in AUTOEXEC.BAT file, for example: C:\DOS\DRV\Smartdrv.exe /X A- B- C+ /U /N /L /V 128 /E:2048 /B:4096 where: C:\DOS\DRV\ path example to SMARTDRV.EXE driver. /X disable write-behind caching for disks, except those enlisted after the /X parameter with plus sign (as C+). On disks followed by minus sign (as A, B) read-ahead buffering is disabled too. If the /X parameter is omitted, then write-behind caching is enabled only for HDDs. /U don't load CD-ROM caching module. /N allow to accept the next command when write cache is not written yet onto disk. This parameter affects those drives only, where write-behind caching is enabled. If the /N parameter is omitted, command prompt does not appear until cache writing to disk operation terminates.

113

Chapter 5 Selected drivers for MS-DOS7


/L forces to arrange cache buffer in conventional memory. This is needed, when DMA controller has no access to UMB address space. /V display status message (by default nothing is displayed, when SMARTDRV.EXE is launched for the first time). Instead of /V there may be /S display status message and cache statistics. 128 cache size in kilobytes. It must be specified, if a large part of XMSmemory is to be used for other purposes, for example, as a RAM-disk. /E:2048 size in bytes of transferred data blocks; 1024, 2048, 4096 and 8192 are allowed, 8192 is the default. /B:4096 size in bytes of read-ahead buffer, it must be a multiple of transferred data block, 16384 is the default.

When SMARTDRV.EXE is running yet, it may be called from command line with other set(s) of options for execution of a command or for reconfiguration, for example: C:\DOS\DRV\Smartdrv.exe /X C D+ /R /F /Q where: /X disable write-behind caching for all disks (if not followed by particular disk's letter-names). This parameter may be applied, if write-behind caching was not disabled in current state of SMARTDRV.EXE. Here C and D+ letter-names mean disable write-behind caching for disk C: and enable it for disk D:. clear the cache and restart SMARTDRV.EXE. One more operation to be performed immediately (instead of /R) is /C write information currently present in write-behind cache to disk. discard the /N parameter, if it is active in current state, and return to default state, when command prompt doesn't appear until cache writing operation terminates. If the state should be reversed in opposite direction, then /N parameter should be specified instead of /F. cancel default status message display. Instead of /Q there may be /S display status message plus cache statistics.

/R /F

/Q

Note 1: /C operation (writing cache) ignores /V and /S parameters, nothing is displayed. Note 2: DMA data transfer, arranged by SMARTDRV.EXE driver, doesn't involve operations, performed by SHSUCDX.COM (5.08-04). Note 3: in order to cope with SATA drives and with UltraDMA data transfer the UIDE.SYS cache driver should be preferred. This driver can be downloaded from site http://johnson.tmfc.net/dos/driver.html . 5.06-02 Double buffering driver DBLBUFF.SYS

The DBLBUFF.SYS driver provides compatibility for some HDD controllers, which otherwise may be unable to work with EMS memory and with WINDOWS OS. In

114

Chapter 5 Selected drivers for MS-DOS7


particular, double buffering may be needed for HDDs with SCSI interface. The DBLBUFF.SYS driver is included in WINDOWS-95/98 release and normally can be found in \WINDOWS directory. A way of loading DBLBUFF.SYS depends on contents of configuration parameter file MSDOS.SYS (5.01-01). If there is a line with "DoubleBuffer=1" parameter, then MSDOS7 will attempt to load DBLBUFF.SYS by default. Otherwise it should be loaded explicitly by DEVICE command (4.06) from a line in CONFIG.SYS file: DEVICE=C:\DOS\DRV\Dblbuff.sys /D+ where: C:\DOS\DRV path example to DBLBUFF.SYS driver. /D+ an optional parameter, instructing to arrange permanent doublebuffering for all disks. Otherwise only I/O to UMB blocks (5.04-02) will be double-buffered, and it wouldn't be done automatically if it appears to be unnecessary. Note 1: status message, displayed by SMARTDRV.EXE driver (5.06-01), contains a column "buffering". If there is at least one "yes" in this column, then DBLBUFF.SYS driver must be loaded. Note 2: if double buffering is needed, then a non-zero number of secondary buffers should be reserved by BUFFERS (4.03) or by BUFFERSHIGH (4.04) command in CONFIG.SYS file. 5.06-03 DRVSPACE.SYS compressed drive's shell loader

DRVSPACE.SYS is a loader for TSR program DRVSPACE.BIN, which provides on-the-fly compression and decompression for logical disks. Data flow is processed just in the course of access operations. Compression improves disk space usage, since compressed data are written continuously, and free disk space is not lost in partially filled clusters. Files DRVSPACE.SYS and DRVSPACE.BIN are included in WINDOWS-95 release and normally must be written in the same directory outside compressed region of logical disk (most often in the root directory). When MS-DOS7 discovers presence of a compressed region on the bootable disk, both DRVSPACE.SYS and DRVSPACE.BIN are loaded by default. Default loading may be discarded either by a line with parameter "DRVSPACE=0" in MSDOS.SYS file (5.01-01) or by a "DOS=NOAUTO" command in CONFIG.SYS file (4.08, 9.01-01). When DRVSPACE.SYS is to be loaded explicitly, it should be loaded before memory managers (5.04-01, 5.04-02) just as a driver by DEVICE command (4.06) from a line of CONFIG.SYS file, for example: DEVICE=C:\Drvspace.sys /MOVE /NOHMA /LOW

115

Chapter 5 Selected drivers for MS-DOS7


where: C:\ path example to DRVSPACE.SYS loader. /MOVE initiates relocation of DRVSPACE.BIN from upper part of conventional memory into UMB or HMA areas, because original placement may be incompatible with other software. Relocation takes place after execution of all DEVICE and DEVICEHIGH commands in CONFIG.SYS file. If address space beyond 640 kb is inaccessible, the /MOVE option induces relocation to lower part of conventional memory. /NOHMA don't relocate TSR compression module into HMA (1024 1088 kb). /LOW forces relocation of TSR compression module into lower part of conventional memory even when address space beyond 640 kb is accessible. When DRVSPACE.BIN is loaded, the DRVSPACE word becomes a command, invoking a dialog shell. This shell gives an opportunity to convert ordinary disks (and diskettes) into compressed ones and back, to create new compressed disks, to test and defragment compressed disks, to arrange protection of compressed disk space, etc. Disk compression with DRVSPACE hasn't got much success because of several reasons. The first is incompatibility with other versions of DOS and with other operating systems (WINDOWS-95 is an exception). The second reason is that compression makes disks more vulnerable to possible errors and less accessible for data recovery procedures. The third reason is that nowadays the problem of disk's space is not so acute, as in early 1990-ties. Large and fast modern disk drives make compression "on the fly" not worth that loss of access speed, which is caused by compression and decompression operations. This is why DRVSPACE usage is not included in examples of configuration files, presented in chapter 9. Note 1: the DRVSPACE.BIN program provides compression for logical disks formatted with file systems FAT-12 or FAT-16. Disks formatted with FAT-32 can't be compressed by DRVSPACE.BIN.

5.07
5.07-01

Interface controller's drivers


ATAPI interface BIOS extension: ATAPIMGR.SYS

Disk drives with Integrated Drive Electronics (IDE) were developed by Western Digital Corp. and were employed for the first time in IBM's PC-AT in 1984. Since then such drives became the most widely used. Protocol of IDE drive's interaction with HDD

116

Chapter 5 Selected drivers for MS-DOS7


controller has been named ATA (= Advanced Technology Attachment). In 1994 it has got status of standard ANSI X3.221-1994. With advent of CD-ROMs and other types of removable drives the ATA protocol was supplemented with new commands, including those for packet data transfer, and since 1998 became known as ATA Packet Interface, or ATAPI. In computers, produced after 2003, the ATAPI interaction protocol is implemented by PC's BIOS. A specific symptom of ATAPI support is BIOS's ability to load OS from optical DVD discs. In those PCs, which can't load OS from DVD disks, the ATAPI functions may be provided by interface driver ATAPIMGR.SYS, developed under "Panasonic" trade mark by Matsushita Corp. Due to this driver a standard (obsolete) IDE controller becomes able to give access to DVD disks, to removable magnetic, magnetooptical and solid-state media of high capacity. SFX archive 85X_DOS.EXE, containing version 2.04 of ATAPIMGR.SYS driver, can be downloaded from internet site http://panasonic.co.jp/pcc/products/drive/internal/support/info_dd2.html . The ATAPIMGR.SYS driver should be loaded from CONFIG.SYS file before any other driver, which will need ATAPI interface support. A line loading the ATAPIMGR.SYS driver with DEVICE (4.06) or DEVICEHIGH (4.07) command may look like this: DEVICE=DOS\DRV\Atapimgr.sys /P:170,15 /W:2 /NDR /NRS /C:2 /T:5 /LUN where: DOS\DRV\ path example to ATAPIMGR.SYS driver. /P:170,15 hexadecimal address of I/O port and decimal interrupt request line number (IRQ). Allowable port addresses are 1F0, 170, 1E8, 168 (A.14-1). Allowable IRQ numbers are 10, 11, 12, 14, 15. If /P parameter is omitted, the driver will search for disk drives throughout all mentioned port addresses and IRQ lines. /W:2 number of waiting cycles (0 99 allowed) for data I/O operations in old PCs, not supporting readiness confirmation (IOCHRDY) check. Recommended number of waiting cycles depends on CPU clock frequency: for 50 MHz /W:2, for 75 MHz /W:6, for 100 MHz /W:9, for 166 MHz /W:19, for 240 MHz /W:30. For PCs with higher CPU clock frequency the /W parameter is not needed. /NDR don't issue the reset command to CD/DVD-ROM drives. This option is essential for booting from a CD/DVD disc, since otherwise the reset command will disrupt booting process. /NRS don't return request sense confirmation, when drive sends a request for conditions check. /C:2 recalculate PIO mode for a particular drive: 0 for master drive at primary IDE controller, 1 for slave drive at primary IDE controller,

117

Chapter 5 Selected drivers for MS-DOS7


2 for master drive at secondary IDE controller, 3 for slave drive at secondary IDE controller. set timeout (in seconds) for waiting drive's response; default is 30 seconds. selectively support addressing to a device with LUN (= Local Unit Number) zero. The LUN numbers enable to regard multifunctional disc drives as different devices, for example, a drive with inserted DVD-RAM disc as equivalent of hard disk drive, and the same drive with inserted CD-ROM disc as an ordinary CD-ROM drive. Addressing with LUN numbers is not supported by default.

/T:5 /LUN

If "above" MS-DOS7 with loaded ATAPIMGR.SYS the Windows-95/98 OS is launched, the latter will run in "MS-DOS compatibility mode" unless you add the following line into the \Windows\IOS.INI file: ATAPIMGR.SYS ; MKE ATAPI Manager If ATAPIMGR.SYS driver will find, that ATAPI interface functions are supported yet by PC's BIOS, it wouldn't be loaded. When ATAPIMGR.SYS is not loaded, some CD-ROM drivers (in particular, SR_ASPI.SYS) wouldn't be loaded too. Hence, in cooperation with ATAPIMGR.SYS those CD-ROM drivers should be preferred, which use ATAPI functions regardless of their origin, for example, as OAKCDROM.SYS (5.09-01) and VIDE-CDD.SYS (5.09-02). Such drivers provide access to DVD-ROM discs in any case, whether ATAPIMGR.SYS will "agree" to be loaded or not.

5.07-02

PCMCIA interface drivers

Since early 1990-ies portable PCs of "notebook" class were equipped with special 68-pin slot for external memory expansion cards. Interface for these cards was standardized in 1990 by PC Memory Card International Association (PCMCIA). In 1995 it was renamed into PC card interface, because at that time it was also used for a variety of peripheral equipment: modems, external disk drives, etc. The last 8-th version of PC card interface standard was adopted in 2001. Later PC card interface was ousted by USB 2.0 interface (5.07-05). In early 1990-ies there were several mutually exclusive types of PCMCIA controllers, and then external devices with PCMCIA interface had to be supplied with a number of PCMCIA drivers for DOS. Thus, CD-ROM drive Panasonic KXL-DN720A (1995) was supplied with 3 drivers for different PCMCIA controllers. These drivers enable to address the device with unified ASPI commands, just as devices with SCSI (5.07-03) or USB interface (5.07-05). This set of drivers, packed into SFX archive 720PCM32.EXE, can be downloaded from server ftp://ftp.panasonic.com/pub/Panasonic/Drivers/CDROM/ .

118

Chapter 5 Selected drivers for MS-DOS7


Later PCMCIA controllers of i82365 type and those compatible with i82365 have ousted all other types. Most modern portable PCs are sold with pre-installed WINDOWS operating system, and are not supplied with PCMCIA drivers for DOS. In order to enable usage of external disk drives with PCMCIA interface for emergency maintenance, some hardware vendors have developed PCMCIA drivers, which directly address from DOS to ports of i82365 controller. In particular, such drivers are proposed by Novac Co: driver NVIHD.EXE for non-optical storage devices and driver NVICDF.EXE for optical disc drives. From site http://www.driver.novac.co.jp/driver/hd150p/hd150p_drv.html you can download archive compact_PCMCIA.zip with version 4.0 (2000) of NVIHD.EXE driver. Version 4.0 (2001) of NVICDF.EXE driver, packed in archive FDOS.ZIP, can be downloaded from http://www.driver.novac.co.jp/driver/sta_PCMCIA/pcm_drv.html . Both mentioned Novac's PCMCIA drivers should be loaded without parameters by DEVICE (4.06) or DEVICEHIGH (4.07) command from a line of CONFIG.SYS file. Then, after a storage device card is inserted into a PCMCIA slot, the same driver should be launched from command line once more, for example Nvicdf.exe /E or Nvihd.exe /E /I where parameters mean: /E initialize PCMCIA card; /I spin drive's motor. The NVICDF.EXE driver doesn't need the /I parameter, because motor in optical disc drives is activated automatically, just after insertion of optical disc. Given information about the mentioned PCMCIA drivers should be treated with some caution, since the author had no opportunity to test these drivers. Note 1: Windows-ME release includes a DOS PCMCIA driver CARDDRV.EXE for external storage devices. However, exact information about it hasn't been found.

5.07-03

SCSI interface drivers

Small Computer's System Interface (SCSI) has been developed in 1982 by Shugart Co. and became widely known due to its implementation in PCs of Apple Co., which were popular then. In 1986 SCSI interface has got status of standard ANSI X3.131-1986. Since then it has been modernized several times. For AT-compatible PCs the SCSI bus is a rare requisite, it is used predominantly in servers. Because of this reason SCSI bus driver's features are not described here in detail. Nevertheless a short survey of SCSI bus access principles is given below.

119

Chapter 5 Selected drivers for MS-DOS7


SCSI bus access may be provided either by PC's BIOS or by special drivers. Server's motherboards usually have embedded SCSI controller and BIOS extensions, enabling to access SCSI devices just as IDE devices, without special SCSI drivers. Known BIOS extensions need at least one active device to be present on SCSI bus when PC starts, and wouldn't be loaded otherwise. Removable disk drives without media inside are considered inactive. If a particular removable SCSI drive must be taken under BIOS control (for example, in order to be formatted as a HDD), you should manage to insert a media in this drive before BIOS launches its start tests. If BIOS senses a valid media inside a SCSI drive, the latter can be used to boot the PC, but beforehand you have to mark this drive as bootable in BIOS setup options. Those SCSI drives, which are initially registered by BIOS as inactive, can't be taken under BIOS control, even if SCSI BIOS extensions are loaded and provide access to other drives. Some SCSI controllers on extension boards have internal read-only memory, containing BIOS software extensions for SCSI bus, and then SCSI bus access is just as that provided by embedded controllers. You can easily determine presence of BIOS software extensions by exploring BIOS setup options. However, most cheap SCSI extension boards have no BIOS software extensions. SCSI devices, which are not supported by BIOS software extensions, can't be used to boot the PC, and access should be arranged by drivers. This form of access is preferable for removable disk drives, because many drivers are able to register each current media partition structure (while most BIOS versions register media partition structure only once at start-up). SCSI driver sets for DOS have been developed by several vendors; the most known are Adaptec, DTC, Mylex, Tekram. Each driver set consists of SCSI controller driver (ASPI8U2.SYS from Adaptec, AS80DOS.SYS from DTC, etc.), HDD driver for SCSI (ASPIDISK.SYS from Adaptec, DISKDOS.SYS from DTC, etc.) and a CD-ROM driver for SCSI (ASPICD.SYS from Adaptec, CDDOS.SYS from DTC, etc.). Drivers of either set must be loaded by DEVICE or DEVICEHIGH command from a line in CONFIG.SYS file. SCSI controller driver always must be loaded in advance, before drivers for other devices connected to SCSI bus. Drivers for HDDs and CD-ROMs, proposed by SCSI controller vendors, accept standardized ASPI command codes and are suitable for almost any device of the same class with SCSI interface. This is not true for all devices: those having unique functions definitely need proprietary drivers. Most SCSI controller drivers are suitable for series of SCSI controller types. Emergency diskettes for Windows-95/98 include two sets of SCSI drivers: from Adaptec and from Mylex. This is often thought to be enough for almost any PC with SCSI bus. In any case configuration file(s) on these diskettes may be taken as example of loading drivers for SCSI bus.

120

Chapter 5 Selected drivers for MS-DOS7


5.07-04 IEEE1394 (FireWire) interface drivers

The FireWire interface has been developed by Apple Company in 1987 for connecting devices having large data transfer rates, up to 393 Mb/sec. Such data transfer rates are typical for video cameras, for video storage devices, for external hard disk drives. Since 1995 the FireWire interface specification has been adopted as standard IEEE1394. For AT-compatible PCs expansion cards with IEEE1394 interface controllers are produced, but up to now the FireWire interface hasn't become widely used. Now two drivers for IEEE1394 interface controllers are known, which are claimed to be suitable under MS-DOS7. The first is ASPI1394.SYS driver, developed by Iomega Company. From site http://www.stefan2000.com/darkehorse/PC/DOS/Drivers/USB/ you can download archive iomega_usb_firewire_dos_driver_boot_disk.zip with version 1.01 of ASPI1394.SYS driver (dated 2002). Just there is an example of loading this driver, but explanation of parameters isn't given. Version 1.02 of another driver SBP2ASPI.SYS, developed by Medialogic Company, is contained in SFX archive DAT.EXE, which can be downloaded from site http://www.datoptic.com/fw25fr.html . Since both mentioned drivers implement the same unified set of ASPI commands, hence for HDDs and for CD-ROM drives, connected via IEEE1394 bus, potentially just those drivers are suitable, which are used for devices of the same class on SCSI bus (5.07-03) and on USB bus (5.07-05). But this feature hasn't been tested by the author, and is reported here for contemplation only.

5.07-05

USB interface drivers

Universal Serial Bus (USB) is a joint development of Compaq, Intel, Microsoft and NEC. In 1996 these companies have adopted version 1.0 of USB bus specification. Since then an embedded USB controller has become ordinary requisite of motherboards in almost all AT-compatible computers. Practical importance of USB bus has increased even more in 2002 with adoption of USB 2.0 specification, stipulating data transfer rates up to 480 Mb/s. Now a vast majority of external devices is designed for connection via USB bus. USB controllers implement three different types of interaction with PC's software: Open Host Controller Interface (OHCI), Universal Host Controller Interface (UHCI), Enhanced Host Controller Interface (EHCI). Each type of interaction needs a specific treatment. All modern USB controllers match USB 2.0 specification and implement EHCI type of interaction, but are able to simulate USB controllers of previous generation, implementing either OHCI or UHCI type of interaction. UHCI controllers transfer data via an allotted port, whereas OHCI controllers

121

Chapter 5 Selected drivers for MS-DOS7


transfer data via a buffer zone in memory. The OHCI type of interaction is implemented by chipsets from SIS and ALI, whereas UHCI by chipsets from INTEL, VIA and some others. Access from DOS to peripheral devices, connected via USB bus, can be provided either by PC's BIOS system or by loaded drivers. Access provided by BIOS is necessary, when operating system must be loaded from an external storage device. Solutions of this problem are considered in detail in article 9.11-01. But PC's BIOS is not necessarily ready to cope with any external device: some BIOS systems accept external devices of a certain class only, for example, floppy drives with USB interface. Besides that, BIOS systems register properties of storage media only once, just after PC is switched on. If, for example, in a USB adapter slot the originally inserted storage card will be replaced by some other card, then BIOS wouldn't provide access to that other card. An opportunity to access removable storage media can be obtained by loading an appropriate driver for storage devices of a particular class. In order to avoid possible conflicts between driver(s) and PC's BIOS, parameter "Legacy USB support" on page "Advanced" of BIOS Setup settings should be set to "Disabled". If there is no similar parameter(s) in BIOS Setup settings of your computer, then, most probably, this BIOS system doesn't support USB storage devices. Access to media in these devices is still possible, but only by means of appropriate driver(s). Generally, USB controller driver should be loaded first, and then drivers for all USB devices, which you intend to use. The very first drivers for USB controllers UHCI.EXE and OHCI.EXE were developed in 1998 2001 by SoftConnex Co. Version 2.3 of these drivers is present in bootable diskettes, formed by a known software packet Norton Ghost (up to it's version 8.0). Version 2.5 of the same drivers can be downloaded from internet site http://www.stefan2000.com/darkehorse/PC/DOS/Drivers/USB/ . In order to suffice any USB controller, the mentioned drivers should be loaded sequentially, one after the other, but actually only one of them will be loaded the one that corresponds to interaction type, implemented by a particular USB controller. Loading may be performed either just from command line, or by LH command (3.17) from a line of AUTOEXEC.BAT file, or else by DEVICE (4.06) or DEVICEHIGH (4.07) command from a line of CONFIG.SYS file, for example: DEVICEHIGH = \DOS\DRV\Uhci.exe DEVICEHIGH = \DOS\DRV\Ohci.exe Drivers from SoftConnex Co. are devised for USB keyboards, for USB mouse pointing devices and for external ports on USB bus. Obviously, a driver for a particular external device should be loaded afterwards. In particular, for mouse pointing devices any of those drivers will suit, which are described in part 5.03. But you have to connect your external device to port of the first USB controller, because all other USB controllers, which may be present in modern computers, can't be detected by drivers from SoftConnex Co. Besides

122

Chapter 5 Selected drivers for MS-DOS7


that, these drivers don't provide functions for access to storage cards and to external disk drives. Problem of access from DOS to USB storage devices has become especially urgent now. There is a lot of different advices about that in various internet sites. Author of this book had to undertake some experiments in order to form his own opinion. In these experiments the role of a drive under test was played by USB adapter ImageMate-2 for Compact Flash cards. Among USB controller's drivers the USBASPI.SYS driver from Matsushita (trade mark Panasonic) has been acknowledged the best. Latest version 2.27 of this driver (dated 22.10.2008), packed into SFX archive F2H_USB.EXE, can be downloaded from site http://panasonic.co.jp/pcc/products/drive/other/f2h_usb.html . This driver is able to detect all active USB controllers of any type. Then it scans each USB bus, and registers all connected devices with all their LUN numbers (see note 1 to appendix A.03-2 for details). Unlike most other USB drivers, version 2.27 of this driver doesn't cause conflicts with PC's BIOS when "Legacy USB support" parameter is enabled. Complete specification for USBASPI.SYS driver isn't made public. Nevertheless the following options have been discovered: /e activate USB controllers of EHCI class only. /o activate USB controllers of OHCI class only. /u activate USB controllers of UHCI class only. /nocbc don't search for USB adapters in PCMCIA slots. /w display a prompt for the user, that he has to connect and to switch on external device(s), which should be registered on USB bus. /slow decrease speed of polling the connected devices, so that even the most lazy devices have enough time to respond. /v display data about registered USB controllers and about all devices, detected on USB bus(es). /r don't decline loading of the driver because of errors and in case of BIOS's control over USB controller(s). /norst don't send the RESET command to USB devices in order to prevent disruption of OS loading process from one of those devices. The /e, /o, /u parameters give a chance to save some time, if class of USB controller(s) in a particular computer is known in advance. The last two parameters (/r and /norst) are necessary, when operating system is to be loaded from a USB device under BIOS control, because otherwise either the loading process will be disrupted or else other USB devices will be left inaccessible. One more warning: the USBASPI.SYS driver doesn't allow loading of drivers for optical disc drives in advance, even if these disc drives have a non-USB interface. The best driver for mass storage devices is still ASPIDISK.SYS, originally developed by Adaptec for hard disk drives with SCSI interface. But ASPIDISK.SYS has no direct

123

Chapter 5 Selected drivers for MS-DOS7


relation to interface type, because it addresses storage devices via standardized set of ASPI functions, provided by SCSI controller's driver. Since just this set of ASPI functions is provided by USBASPI.SYS driver too, the ASPIDISK.SYS driver is able to cope with storage devices, connected to USB bus. Version 4.01b of the ASPIDISK.SYS driver (size 15060 bytes, dated 02.12.1998) can be got inside SFX archive DOSDRVR.EXE from Adaptec's internet site http://www.adaptec.com/en-US/speed/scsi/dos/dosdrvr_exe.htm . This driver gives access to logical disks with file systems FAT-12, FAT-16, FAT-32 and "Big Floppy". If removable media is not present in the storage device at the moment of initialization, then this storage device will be given one of reserved letter-names. But there are removable media, which may be formatted as hard disk drives with several FAT-16 partitions, each representing a separate logical disk. The ASPIDISK.SYS driver can provide access to all such partitions (including those beyond the first), if an appropriate number of disk's letternames is reserved beforehand by specifying this number after the /r parameter in command line. The whole set of allowed command line options includes the following: /id=2:0+1 an example of specification for devices, which should be taken under driver's control: the device number 2, connected to USB bus of the first USB controller, and devices number 0 and 1, connected to USB bus of the second USB controller. /nospinup don't issue command to switch on drive's motor at the moment of driver's initialization. /d display status message about devices, which are taken under driver's control. /pause suspend further execution until any keystroke in order to give an opportunity to read the status message. /r4 an example of request to reserve 4 disk's letter-names for non-first partitions on removable media in drives, taken under driver's control. From 1 to 24 letter-names can be reserved. If specification for controlled devices is not given in command line, then the ASPIDISK.SYS driver will examine each encountered device and will attempt to take under it's control all mass storage devices, even those having no removable media inside at that moment. When specification for controlled devices is given, no time will be lost for examination of unsuitable devices. In the example above the specification of device number 2 means that driver will not examine devices 0 and 1, connected to bus of the first USB controller, since these devices may happen to be, for example, a scanner and a printer. For external optical CD/DVD-ROM drives with USB interface the NJUSBCDA.SYS driver from Workbit Corp. may suffice. Archive BST_DOS.ZIP, containing version 3.9 of NJUSBCDA.SYS driver (dated 2000), can be downloaded from internet site http://www.driver.novac.co.jp/driver/sta_black/bst_drv.html . As many other CD/DVDROM drivers, NJUSBCDA.SYS accepts from command line the /D: parameter, followed

124

Chapter 5 Selected drivers for MS-DOS7


by an arbitrary identifier (for example, /d:USBCD001) of up to 8 characters long. It is used for drive's identification by file system translation utility either MSCDEX.EXE (5.08-03) or SHSUCDEX.EXE (5.08-04), one of which should be loaded afterwards. It should be given exactly the same identifier in its command line. The described drivers of USB devices should be loaded by DEVICE (4.06) or by DEVICEHIGH (4.07) commands from lines of CONFIG.SYS file. Let's assume, that all mentioned drivers are present in the \DOS\DRV directory of bootable disk; then lines for loading these drivers may look, for example, as DEVICEHIGH=\DOS\DRV\Usbaspi.sys /slow /v DEVICEHIGH=\DOS\DRV\Aspidisk.sys /nospin /d /pause DEVICEHIGH=\DOS\DRV\Njusbcda.sys /d:USBCD001 Parameters in the shown example are selected for loading MS-DOS7 from a device with some other (non-USB) interface, when it is not known in advance, how many USB controllers there are in the PC and which devices are connected to USB bus(es). But when PC's hardware is known, and MS-DOS7 loading is performed not for the first time, then parameters /SLOW and /PAUSE may be omitted. Besides that, loading goes faster, if parameters specify the type of USB controller and particular devices, which should be registered. The described USBASPI.SYS driver, developed by Matsushita (version 2.27, file length 39729 bytes), is often messed with synonymous driver, supplied by Novac (version 1.07, file's size 43528 bytes). The latter driver detects only the first USB controller, works according to the USB 1.1 specification exclusively, ignores all devices with non-zero LUN number (note 1 to appendix A.03-2), and accepts from command line a somewhat different set of options: /w display a prompt for the user, that he has to connect and to switch on external device(s), which should be registered by USB controller. /v display data about detected devices on USB bus of the first USB controller. /r don't unload driver's resident module when the first USB controller is under control of PC's BIOS. /m=D0 an example of contact memory zone specification for USB controller of OHCI class. D0 denotes segment addresses zone D000 DFFFh. /p=A400 an alternative example of port address specification for USB controller of UHCI class. The Novac's USBASPI.SYS driver, packed into archive HD352u_dos.zip, can be downloaded from site http://www.driver.novac.co.jp/driver/hd352u/hd352u_drv.html . Besides the USBASPI.SYS driver itself, the HD352u_dos.zip archive contains version 2.0 of the Novac's driver Di1000dd.sys for mass storage devices. The Di1000dd.sys driver accepts from command line parameter

125

Chapter 5 Selected drivers for MS-DOS7


/dS an example of disk's letter-name ("S"), which should be appointed to the logical disk, opened for access by the Di1000dd.sys driver.

However, letter-name appointment by the Di1000dd.sys driver goes "dirty", created dummy disks (phantoms) are not hidden. The Di1000dd.sys driver can't cope with multiple LUN numbers, can't provide access to disks with FAT-32 file system, to devices beyond the bus of first USB controller, needs a media to be present in storage device(s) at the moment of initialization. Though capabilities of both mentioned Novac's drivers seem substantially limited, they may be sufficient for performing main data transfer operations in computers with known hardware. One more way of access to USB storage devices from DOS is opened by combined driver DUSE.EXE, developed by Cypress Semiconductor. Version 4.9 of this driver (dated 2003), packed into archive Duse_4_9.zip, is available in subdirectory "downloads" of site http://www.pocketec.net/support.taf . The DUSE.EXE driver combines USB controller driver with driver for CD-ROMs and with driver for non-optical storage devices, including HDDs and solid-state storage cards. The opportunity to get all-in-one seems attractive, but is accompanied with unexpected and unpleasant surprise. Because of a strange reason DUSE.EXE requires DOS working in real mode only, that is without the EMM386.EXE driver (5.04-02), which gives access to UMB memory region. Having no access to UMBs, DOS is forced to load all drivers into conventional memory (below 640 kb), and then resident module of DUSE.EXE with default settings occupies yet more 233 kb of precious conventional memory, so that no free space is left there for normal operation of other programs. Some tolerable configuration can be obtained, if access to UMB region is provided in real mode by UMBPCI.SYS driver (5.04-04) and if you decline loading of DUSE's CD/DVD-ROM support module. Thus total size of DUSE's resident module has been reduced to 153 kb, but all attempts to load it beyond conventional memory have failed. For comparison: resident modules of USBASPI.SYS and ASPIDISK.SYS drivers provide nearly the same functions, but both occupy 45 kb only and can be loaded beyond conventional memory either in CPU's real mode or in V86 mode as well. If circumstances will force you to use the DUSE.EXE driver, then a line in CONFIG.SYS file for loading DUSE.EXE may look, for example, as DEVICE=\DOS\DRV\Duse.exe NOC EMU XFER=8 where the shown options mean:: NOC decline loading of CD/DVD-ROM support module. EMU emulate IRQ calls in order to prevent driver's mutual incompatibility. XFER=8 reduce buffer size to 8 kb (1 to 64 kb are allowed, default is 64 kb). Whole list of DUSE's options can be found in file DUSEUsersGuide.pdf inside the same archive Duse_4_9.zip. The INT option, proposed there among other options, deserves special notice. It claims to provide an opportunity to divide external HDDs into

126

Chapter 5 Selected drivers for MS-DOS7


partitions with FDISK.EXE utility (6.13), but in fact doesn't. Moreover, making HDD partitions with ASPI functions (note 5 to 6.13) was not available too, either with or without the INT option, whereas the USBASPI.SYS driver enables to do it easily. Two personal attempts to create sets of USB drivers for DOS became known recently. Version 1.0 of driver's set, developed by G.Potthast, appeared in december 2006 at internet site http://www.georgpotthast.de/usb/ . Later, in august 2009, B.Johnson has uploaded version 0.08 of another USB driver's set at his site http://bretjohnson.us/ . The set, developed by G.Potthast, presents drivers for USB controller, for non-optical storage devices and for some types of USB printers. Besides drivers, it includes a number of service utilities, enabling to detect and to fix errors of USB interface configuration. This set of drivers can't determine actual number of USB storage devices, can't detect devices on bus(es) of non-first USB controller(s), requires a media to be present in storage device at the moment of initialization, provides access to the first partition only of a physical disk and has some other considerable drawbacks. The set, developed by B.Johnson, besides the same main drivers and some service utilities, includes drivers for USB keyboard, for USB mouse and provides access to disks formatted with FAT-32. USB controller must be either of UHCI or EHCI type and can be used with 12 Mb/s transfer speed only. Probably, some drawbacks are not revealed yet, because this set of drivers appeared in the last moment and wasn't tested thoroughly. Despite all drawbacks of early versions, those sets of drivers, presented by G. Potthast and by B.Johnson, are worth serious attention. Both sets are still under development, and their future versions may be much better. But the most valuable feature of these driver's sets is their partially opened executable code. There is a lot of interesting details for all those who intend to have a closer deal with USB interface.

5.08
5.08-01

Services for installable file systems


IFSHLP.SYS IFS service driver

Auxiliary driver IFSHLP.SYS provides service functions for IFS (= Installable File Systems) procedures. IFS file system is a form of hiding real data structures and real ways of access, enabling to avoid explicit technical complications and implement selective access rights. Original 16-bit access to storage devices is performed by BIOS's INT 13 handlers, which require CPU's real mode and can't do their job indirectly, for example, via a network. When CPU works in protected mode or in V86 mode, each call to INT 13 handler implies a callback with switches to real mode and back. These switches make a slow 16-bit

127

Chapter 5 Selected drivers for MS-DOS7


access even more slower. Service functions, provided by IFSHLP.SYS driver, enable a much faster 32-bit direct and indirect disk access without callbacks in both protected and V86 modes. But If you intend to work in real mode only and without network communications, then, most probably, the IFSHLP.SYS driver will not be needed. The IFSHLP.SYS driver is present in Microsoft Network Client packet, and also in Windows-3.11\95\98\ME releases. MS-DOS7 searches in the \Windows directory for the IFSHLP.SYS driver and loads it by default, unless default loading is forbidden by DOS=NOAUTO command (4.08) in CONFIG.SYS file.

5.08-02

NTFSDOS.EXE NTFS file system translator

An opportunity of access from DOS to disks with NTFS file system is provided by driver NTFSDOS.EXE, written by Mark Russinovich and Bryce Cogswell. Full-functional versions of this driver (latest the 5-th) were not free. Here a freeware version 3.02 (dated 2001) is described, which enables only reading NTFS volumes, including reading programs into memory for execution. However, NTFSDOS driver and several other helpful items disappeared from their author's personal site since 2006, when the authors joined Microsoft's developers team. Now archive Ntfs30r.zip containing NTFSDOS.EXE driver is still available from, for example, server ftp://ftp.uni-koeln.de/pc/msdos/diskutils/ and from http://web.archive.org/web/20020123013310/www.sysinternals.com/new.shtml . It's just the moment to remind, that Windows-2000/XP installation program, being launched from a CD-ROM disc, gives an opportunity to open the so called Recovery Console. Default settings of the Recovery Console enable writing to NTFS volumes, but prohibit copying of file(s) from NTFS volumes. Consequently, version 3.02 of the NTFSDOS.EXE driver enables to do just what is not allowed by Recovery Console. The NTFSDOS.EXE driver uses XMS-memory and therefore needs the HIMEM.SYS driver (5.04-01) to be loaded beforehand. Besides that, NTFSDOS.EXE needs much space in conventional memory. In particular, for access to a 10 Gb NTFS disk the NTFSDOS.EXE driver occupies 285 kb of conventional memory. Because of such memory requirements it's not reasonable to keep the NTFSDOS.EXE driver constantly loaded. Therefore it is loaded from command line just before access to NTFS disk becomes necessary, for example: C:\DOS\DRV\Ntfsdos.exe /L:K /C:1024 /N /X /U /V where: C:\DOS\DRV\ path example to NTFSDOS.EXE driver. /L:K an option, assigning the "K" letter-name to the first found NTFS disk. The next NTFS disks, if there are any, will be given next letter-names

128

Chapter 5 Selected drivers for MS-DOS7


after "K". If /L: parameter is omitted, NTFS disk(s) name assignment will start from the first free letter-name. /C:1024 an option, forcing to create a 1024 kb cache buffer in XMS memory. Default cache buffer size is 500 kb. /N this option prevents loading of decompression module. It is not needed, when NTFS volume contains no compressed fragments. The /N option decreases conventional memory requirements. /X this option forbids usage of extended INT 13 functions (8.01-55). The /X parameter should be specified for old PCs, produced before 1996 and having a HDD not larger than 8.4 Gb. /U this option enables translation of names written in unicode (two bytes per character). /V this option forces to display driver's memory usage. By default assigned disk's letter-names only are displayed. Note 1: NTFSDOS.EXE driver loads handlers, enabling to read long names of files and directories in NTFS volume(s). Non-truncated names are displayed by Volcov Commander file manager (6.25) and can be got by any program, which is able to address the mentioned handlers. However, file copying commands and utilities in DOS truncate long names. Note 2: attempts of access to disk(s) with damaged NTFS file system may cause PC's hanging. Suspected NTFS file system should be checked and fixed in advance by CHKDSK procedure, provided by Recovery Console.

5.08-03

MSCDEX.EXE optical disc's file system translator

MSCDEX.EXE is a resident program, which cooperates with one or more CD/DVDROM drivers, enables disk's letter-names assignment and access to the associated logical disks. In fact it is a file system translator for CD-ROM's file systems "High Sierra" and ISO 9660, which differ from those "understandable" to DOS' core. The MSCDEX.EXE program is contained in Windows-95/98 releases and normally can be found in \Windows\Command directory. MSCDEX.EXE should be loaded after all necessary CD-ROM drivers, but before SMARTDRV.EXE (5.06-01) cache driver, if the latter is used. Most often the MSCDEX.EXE program is loaded from CONFIG.SYS file with INSTALL (4.15) or INSTALLHIGH (4.16) command, but may be launched from AUTOEXEC.BAT file with LH command (3.17) or just from command line, for example: C:\DOS\DRV\Mscdex.exe /D:MSCD001 /e /k /s /v /L:N /M:12 where: C:\DOS\DRV\ path example to MSCDEX.EXE file.

129

Chapter 5 Selected drivers for MS-DOS7


/D:MSCD001 is an example of arbitrary identifier ("MSCD001") of up to 8 characters long for association with a particular CD/DVD-ROM driver, which must be loaded yet and must be given the same identifier in its command line. If there are several CD/DVD-ROM drivers, these must be given different identifiers, and each must be specified after a separate /D: parameter in command line loading MSCDEX.EXE. /e this option gives preference to arrangement of buffers beyond conventional memory, provided that access beyond conventional memory is opened yet by EMM386.EXE memory manager (5.04-02). /k this option gives preference to secondary volume descriptor with Japanese characters (Kanji), if it can be found. By default primary descriptor is used, secondary descriptor even is not searched for. /s this option forces to make preparations for subsequent loading of network server software; this helps to avoid letter-name allocation conflicts and enables sharing of CD-ROM logical disks. /v display information about status of CD-ROM drives. /L:N optional assignment of letter-name "N:" to the drive, which corresponds to the first /D:MSCD001 identifier; drive(s) related to the following identifier(s), if there are any, will be given the next letternames. By default CD/DVD drive(s) are given the nearest spare letternames, but MSCDEX.EXE can't exceed the limit, set by LASTDRIVE command (4.17) in CONFIG.SYS file. /M:12 is an example of reserving 24 kb of memory for arranging 12 buffers (2048 bytes each) in order to increase reading speed; figures between 4 and 64 are recommended, 12 is the default. Note 1: resident module of MSCDEX.EXE program accepts other program's requests via INT 2F\AX=1500150Fh (8.03-13 8.03-19).

5.08-04

SHSUCDX.COM optical disc's file system translator

In recent years several amendments to CD/DVD-ROM file system specifications have been adopted, stipulating usage of long filenames. The MSCDEX.EXE program (5.08-03) can't cope with modified file systems on optical discs: it shows truncated long names, but gives no access to such files. This drawback isn't inherent to SHSUCDX.COM program; except this, SHSUCDX.COM is a close functional equivalent of MSCDEX.EXE. Development of SHSUCDX.COM program has been started by John McCoy and now is continued by Jason Hood. Archive Shcdx302.zip, containing version 3.02 (dated 2005) of SHSUCDX.COM program, can be downloaded from http://www.shsucdx.adoxa.cjb.net/ .

130

Chapter 5 Selected drivers for MS-DOS7


The SHSUCDX.COM program can be loaded from a line of AUTOEXEC.BAT file by LH command (3.17) or just from command line, but usually it is loaded by INSTALL (4.15) or by INSTALLHIGH (4.16) command from a line of CONFIG.SYS file, for example: INSTALLHIGH=\DOS\DRV\Shsucdx.com /D:?CD001,N,0,2 /~+ /R /Q where \DOS\DRV\ path example to SHSUCDX.COM file /D:?CD001 specification of an arbitrary identifier ("CD001") of up to 8 characters long for association with a particular CD/DVD-ROM driver, which must be loaded yet and must be given the same identifier in its command line. If there are several CD/DVD-ROM drivers, these must be given different identifiers, and each must be specified after a separate /D: parameter in command line loading SHSUCDX.COM. The question mark preceding the identifier marks those drives, which may be absent in some configurations, since PC's hardware may be not known beforehand. ,N,0,2 a group of options for that CD/DVD-ROM driver, which is given the same identifier after the /D: parameter. The first letter ("N") is an example of letter-name to be appointed to the corresponding logical disc. The second digit ("0") is an example of disc drive number in a list of disc drives, controlled by this driver. The third digit ("2") is number example of disc drives, accepted by SHSUCDX.COM program from this driver. By default all disc drives will be accepted, and next disc drives will get letter-names, following the specified letter-name or the first spare letter-name. /~+ this option forces to insert the tilde sign ( ~ ) as the last character in long names, truncated to standard length (8 characters). Action of this option may be cancelled later by launching the SHSUCDX.COM program from command line with inverse parameter /~. /R this option prescribes to take off the "Read only" attribute from files, copied from non-writable optical discs. /Q this option forbids display of status message, the letter-name appointment(s) only will be displayed. If you want just nothing to be displayed, you should specify the /QQ parameter instead. Besides the parameters shown above, SHSUCDX.COM program can accept the following options: /L:N an alternative form of prescription to appoint the specified letter-name ("N") to the first optical disc drive, taken under control of SHSUCDX.COM program. The next disc drives, if there are any, will be given next letter-names. The /L: parameter is equivalent to synonymous parameter of MSCDEX.EXE program (5.08-03). The

131

Chapter 5 Selected drivers for MS-DOS7


SHSUCDX.COM program accepts the /L: parameter if only additional group of options to the /D: parameter is not specified. load resident module of SHSUCDX.COM program into conventional memory. By default resident module is loaded in UMB address space, if it is accessible. show some more details in displayed status message. Having been loaded in advance, SHSUCDX.COM program can be launched with this parameter once more from command line. Obviously, the /V parameter is incompatible with /Q and /QQ parameters. unload resident module of SHSUCDX.COM program from memory. This parameter is accepted from command line only, provided that resident module is loaded yet. Unloading releases occupied memory and disables all logical disks, controlled by that resident module.

/C /V

/U

Note 1: data transfers, arranged by SHSUCDX.COM program, are not supported by SMARTDRV.EXE cache buffer driver (5.06-01), but are supported by UIDE.SYS cache buffer driver (note 3 to 5.06-01).

5.09

Drivers for optical disc drives

Optical disc drives with different interfaces usually need different drivers. Some drivers for optical disc drives with SCSI and USB interfaces are mentioned in articles 5.07-03 and 5.07-05. But in AT-compatible PCs a vast majority of internal disc drives has the IDE (ATA) interface, and drivers for such disc drives are presented here, in part 5.09. Popular types of motherboards are equipped with two IDE controllers. Each of them enables to connect two devices, which may be optical disc drive(s) and magnetic hard disk drive(s) as well. Connection of optical and magnetic drives to one IDE controller is allowed, but can't be recommended, since relatively slow optical disc drives cause reduction of total data transfer rate. It's better to connect optical device(s) to a separate IDE controller, which must be enabled in settings of BIOS Setup program. In modern PCs the BIOS Setup programs propose several operation modes for IDE controllers, including that with polling serial ATA buses only (S-ATA). Since most optical disc drives have parallel ATA interface, a compatible operation mode should be preferred. If BIOS Setup program enables to affect direct memory access (UltraDMA), then an ordinary mode of IDE access should be set ("Legacy IDE mode"). These settings guarantee proper operation of optical disc drives and drivers in modern PCs under MS-DOS7.

132

Chapter 5 Selected drivers for MS-DOS7


5.09-01 OAKCDROM.SYS CD-ROM driver from OTI Corp.

The OAKCDROM.SYS driver is developed by Oak Technology for CD-ROM disc drives with standard IDE interface. OAKCDROM.SYS file, dated 1997, is present in WINDOWS-95/98 emergency diskettes. The same version of OAKCDROM.SYS can be downloaded from site http://www.computerhope.com/download/hardware.htm#02 . In modern PCs, equipped with a DVD drive, the OAKCDROM.SYS driver enables access to both CD and DVD discs. But in PCs, produced before 2003, presence of a DVD drive is not enough, since BIOS system may provide no support for ATAPI protocol (see 5.07-01 for details), and then OAKCDROM.SYS will enable access to CD discs only. In such computers access to DVD discs is still possible, but requires ATAPI protocol support module to be installed in advance by ATAPIMGR.SYS driver (5.07-01). The OAKCDROM.SYS driver should be loaded by DEVICE (4.06) or DEVICEHIGH (4.07) command from a line of CONFIG.SYS file, for example: DEVICEHIGH=\DOS\DRV\Oakcdrom.sys /D:MSCD001 /V where: \DOS\DRV\ path example to OAKCDROM.SYS driver. /D:MSCD001 announcement of an arbitrary identifier up to 8 characters long. This identifier enables recognition of the driver by MSCDEX.EXE program (5.08-03) or by SHSUCDX.COM program (5.08-04). One of these should be loaded afterwards, and it must be given the same /D: parameter followed by exactly the same identifier in its command line. /V this option causes status message display. The OAKCDROM.SYS driver is able to search for CD/DVD-ROM disc drives throughout all IDE-controllers having typical port addresses (1F0h, 170h) and typical interrupt request (IRQ) line numbers. If PC is equipped with several such disc drives, the OAKCDROM.SYS driver will take under its control all drives, which will be found. 5.09-02 VIDE-CDD.SYS CD-ROM driver from Acer Co.

Version 2.14 of the VIDE-CDD.SYS driver, dated 1998, is a close functional equivalent of OAKCDROM.SYS driver (5.09-01), but VIDE-CDD.SYS is more compact (size 11.8 kb) and can accept port address(es) together with IRQ line number(s) from command line. The latter feature is important when non-standard interface specifications are used, and search for disc drives must be avoided. SFX archive Apicd214.exe, containing VIDE-CDD.SYS driver, can be downloaded via internet, for example, from ftp://ftp.benq.co.uk/cd-rom/drivers/apicd214.exe . If PC's BIOS doesn't support ATAPI protocol, then VIDE-CDD.SYS can provide access to DVD discs, but needs the ATAPIMGR.SYS driver (5.07-01) to be loaded in

133

Chapter 5 Selected drivers for MS-DOS7


advance. VIDE-CDD.SYS must be loaded from a line in CONFIG.SYS file with DEVICE (4.06) or DEVICEHIGH (4.07) command, for example: DEVICEHIGH=\DOS\DRV\Vide-cdd.sys /D:MSCD001 /P:170,15 where: \DOS\DRV\ path example to VIDE-CDD.SYS driver. /D:MSCD001 announcement of an arbitrary identifier up to 8 characters long. This identifier enables recognition of the driver by MSCDEX.EXE program (5.08-03) or by SHSUCDX.COM program (5.08-04). One of these should be loaded afterwards, and it must be given the same /D: parameter followed by exactly the same identifier in its command line. /P:170,15 an optional specification for port base address and for interrupt request line number (IRQ). There may be more than one /P parameter specified in one line. When at least one /P parameter is given, all other port addresses and IRQ line numbers will not be examined. When /P parameter is omitted, a search for CD/DVD-ROM drives will be initialized throughout all typical IDE port addresses and IRQ line numbers: /P:1F0,14, /P:170,15, /P:1E8,12, /P:168,10 (A.14-1). The VIDE-CDD.SYS driver will take under its control all optical disc drives, which will be found. 5.09-03 QCDROM.SYS a freeware CD/DVD-ROM driver

Version 4.2 of QCDROM.SYS driver was developed in 2007 by J. R.Ellis on the basis of his earlier driver XCDROM.SYS. Contrary to the latter, the QCDROM.SYS driver is able to provide access to DVD discs and doesn't need ATAPI protocol support neither from PC's BIOS, nor from ATAPIMGR.SYS driver. The QCDROM.SYS driver can control up to three CD/DVD-ROM drives, connected to IDE controller(s) with standard port base address(es) and standard interrupt request line(s): 1F0h with IRQ 14 and/or 170h with IRQ 15. The QCDROM.SYS driver, packed into archive QCDROM42.ZIP, can be downloaded from internet site http://cyberia.dnsalias.com/Cyb.05.Htm . QCDROM.SYS should be loaded by DEVICE (4.06) or DEVICEHIGH (4.07) command from a line of CONFIG.SYS file, for example: DEVICEHIGH=\DOS\DRV\Qcdrom.sys /D:MSCD001 /L where: \DOS\DRV\ path example to QCDROM.SYS driver. /D:MSCD001 announcement of an arbitrary identifier up to 8 characters long. This identifier enables recognition of the driver by MSCDEX.EXE program (5.08-03) or by SHSUCDX.COM program (5.08-04). One of

134

Chapter 5 Selected drivers for MS-DOS7


these should be loaded afterwards, and it must be given the same /D: parameter followed by exactly the same identifier in its command line. If the /D: parameter is omitted, QCDROM.SYS will appoint default identifier QCDROM1. this option prescribes to refrain from direct memory access (DMA) beyond conventional memory (640 kb). This may be necessary, when PC's memory controller doesn't support DMA access to UMB memory region, while UMBs are opened for ordinary access, for example, by UMBPCI.SYS driver (5.04-04). If the /L option is specified, then data transfer is performed via a buffer in XMS-memory; therefore in this case the HIMEM.SYS driver (5.04-01) must be loaded in advance.

/L

Besides the shown parameters, QCDROM.SYS driver can accept from command line the following options: /A forces to use old alternate IDE controller addresses 01E8h01EFh on primary channel, and 0168h-016Fh on secondary channel. This may be required for "odd" SATA BIOS or other unusual cases. /I forces QCDROM.SYS to arrange its own XMS buffer. This enables to avoid possible conflicts with "odd" DMA and BIOS services. /UF prescription to enable accelerated direct memory access (UltraDMA). Feasibility of UltraDMA is confirmed for many motherboard's chipsets, but not for all. A check whether the /UF parameter is permissible can be recommended for each particular case. /UX refrain from UltraDMA usage, even if both disc drive and motherboard claim support for UltraDMA. The /UX option is used for diagnostics and testing purposes. When /UX option is specified, the QCDROM.SYS driver doesn't need XMS memory. /PM (= Primary Master): don't search for disc drives, but check presence of master disc drive only on the bus of primary IDE controller. /PS (= Primary Slave): don't search for disc drives, but check presence of slave disc drive only on the bus of primary IDE controller. /SM (= Secondary Master): don't search for disc drives, but check presence of master disc drive only on the bus of secondary IDE controller. /SS (= Secondary Slave): don't search for disc drives, but check presence of slave disc drive only on the bus of secondary IDE controller. Up to three parameters, prohibiting search for disc drives, may be specified in one command line. Disc drives will be numerated according to order of corresponding parameters in command line. If specified checks don't reveal presence of disc drive(s), then all other optical disc drives will be ignored, and resident module of QCDROM.SYS driver wouldn't be loaded.

135

Chapter 5 Selected drivers for MS-DOS7


5.09-04 DVS.SYS CD/DVD-ROM driver from DVS Corp.

The DVS.SYS driver has been developed in 1999 by Digital Video Systems Corp. DVS.SYS driver is able to provide access to DVD discs and doesn't need ATAPI protocol support neither from PC's BIOS, nor from ATAPIMGR.SYS driver. Version 1.1 of DVS.SYS driver, packed into SFX archive Drdvdwd.exe, can be downloaded from internet site http://web.archive.org/web/20030212210152/www.dr-tech.com/drivers/cdroms.html . The DVS.SYS driver should be loaded by DEVICE (4.06) or DEVICEHIGH (4.07) command from a line of CONFIG.SYS file, for example: DEVICEHIGH=\DOS\DRV\Dvs.sys /D:MSCD001 where: \DOS\DRV\ path example to DVS.SYS driver. /D:MSCD001 announcement of an arbitrary identifier up to 8 characters long. This identifier enables recognition of the driver by MSCDEX.EXE program (5.08-03) or by SHSUCDX.COM program (5.08-04). One of these should be loaded afterwards, and it must be given the same /D: parameter followed by exactly the same identifier in its command line. The DVS.SYS driver is able to search for disc drives, but performs search more slowly, than other similar drivers. An experiment has confirmed, that DVS.SYS driver can take under its control at least two optical disc drives, connected to either of IDE controllers with standard specifications of port base addresses and interrupt request line numbers (1F0h with IRQ 14 and/or 170h with IRQ 15).

136

Chapter 6.
6.01 6.02 6.03 6.04 6.05 6.06 6.07 6.08 6.09 6.10 6.11 6.12 6.13

Selected utilities for MS-DOS7


138 138 139 141 143 162 163 165 166 168 169 171 172 6.14 6.15 6.16 6.17 6.18 6.19 6.20 6.21 6.22 6.23 6.24 6.25 6.26 Find.exe Format.com Label.exe Mem.exe Mode.com More.com Move.exe Scandisk.exe Sort.exe Subst.exe Sys.com Vc.com Xcopy.exe 174 176 178 179 179 182 183 184 186 187 188 189 204

Attrib.exe Chkdsk.exe Choice.com Command.com Debug.exe Diskcopy.com Doskey.com Deltree.exe Edit.com Expand.exe Extract.exe Fc.exe Fdisk.exe

Functions of command interpreter in MS-DOS7 are complemented and extended by separate executable files (utilities). Several utilities for DOS are supplied within Windows-95/98 OS release. If the origin of utility is not specified explicitly in this chapter, hence, it is one of these Microsoft's utilities, which normally can be found in \Windows\Command directory. Besides these, many other utilities can be successfully used in MS-DOS7, including those from previous versions of DOS and those written by various private and non-private software vendors. MS-DOS utilities contain internal help text. It can be displayed, when the utility is launched from command line with a single "/?" parameter. Rarely other utilities can be encountered, which display help text when are launched with "h" parameter or without parameters at all. Some MS-DOS utilities request DOS version number and wouldn't perform their mission, if the number, returned by DOS, isn't equal to the expected one. It is not necessarily caused by incompatibility: most such version-specific utilities successfully operate under MS-DOS7, when the Setver.exe driver (5.01-02) substitutes expected version number from its table for the actual DOS version number. Mismatch of DOS version numbers may cause a problem of other kind: when a synonymous utility, belonging to a different DOS version, is encountered in the current directory, the proper utility from MS-DOS7 can't be addressed via the PATH environmental variable (2.02-02), because DOS begins its search in the current directory and finds the improper utility first. In MS-DOS7 version-specific utilities are: Attrib.exe,

137

Chapter 6: Selected utilities for MS-DOS7


Chkdsk.exe, Command.com, Debug.exe, Diskcopy.com, Doskey.com, Fc.exe, Find.exe, Format.com, Label.exe, Mem.exe, Mode.com, Sort.exe, Subst.exe, Xcopy.exe. There is one obvious solution for this problem: name of each version-specific utility in command line should be preceded by full path. It will be wise to prepare special batch files or file manager's menu entries for execution of version-specific utilities with properly specified paths (examples - in 9.03). Most examples of utilities usage, presented in this chapter, contain no path specifications. It's implied, that the Setver.exe driver, the PATH environmental variable value and file's placements are prepared in advance so, that each particular utility can be called just by name.

6.01

ATTRIB.EXE attribute changing utility

In directories each file is represented by a record (A.09-1). Attribute byte 0Bh in this record specifies file's status and rights of access (A.09-2). Attribute byte 0Bh in record(s), related to particular file(s), can be changed by ATTRIB.EXE utility, launched, for example, in the following way: Attrib.exe +R A C:\DOS\COM\*.txt /S where: +R A set attribute R (read-only) and remove attribute A (prescribed for archiving); there may up to four attributes specified: A, H (hidden), R and S (system), each preceded by "+" (to be set up) or "" (to be removed). Attributes, which are not mentioned, remain unchanged. C:\DOS\COM\*.txt an example of path and mask specifications for the files to be processed (= all textual files in C:\DOS\COM directory). If path is not specified, files in current directory are implied. A particular filename may be used instead of a mask. /S this option prescribes to continue the search for file(s) to be processed in subdirectories of the specified (or of implied current) directory. Note 1: if attributes are not specified in command line, the ATTRIB.EXE utility shows which of the requested files have been found and displays a summary of their features, including attributes.

6.02

CHKDSK.EXE disks checking tool

CHKDSK.EXE is a utility for analyzing and repairing FAT (File Allocation Tables) on diskettes and on hard disk drives, formatted with file systems FAT12, FAT16 or FAT32. By comparing data in first and second FAT tables (and in directories as well), CHKDSK.EXE reveals crosslinks and lost clusters. The latter are transformed into files

138

Chapter 6: Selected utilities for MS-DOS7


with *.CHK suffix, written in the root directory of the same disk. Having finished the check, CHKDSK.EXE shows a summary of results. Being executed without parameters, CHKDSK.EXE checks the current disk with default settings. Besides this, you may specify the following options: Chkdsk.exe C: /F /V where: C: /F /V specification example for the disk to be checked. permission to fix the found errors at once. prescription to display name of every processed file with full path.

Note 1: the SCANDISK.EXE utility (6.21) performs the all the checks which CHKDSK.EXE does, and some extra checks besides that. Therefore CHKDSK.EXE is worthy only as an information utility, displaying summary of disk's usage. Note 2: CHKDSK.EXE shouldn't be applied to network drives, CD-ROMs, and to virtual disks, arranged by utilities Assign.com, Subst.exe and Join.exe. Note 3: the CHKDSK.EXE utility doesn't check whether the files are readable or damaged. Note 4: the CHKDSK.EXE utility with /F parameter shouldn't be applied to disks suspected of being infected by virus: an antivirus program should be applied first. Note 5: the CHKDSK.EXE utility shouldn't be applied to disks having from 4085 to 4087 clusters, because it may report nonexistent errors in such disks, and an attempt to fix these errors may destroy stored data.

6.03

CHOICE.COM choice input utility

The CHOICE.COM utility is intended for arranging interactive menu in the course of batch file(s) execution by command interpreter. CHOICE.COM accepts a character, sent from keyboard or via redirection, and then sets ERRORLEVEL value (3.15-03, 9.07-03) according to the number of the accepted character in a succession of prescribed alternatives. Here is an example of CHOICE.COM usage, charged with its main mission: Choice.com /C:YNC /T:C,10 Yes, No or Continue where the options are:: /C:YNC the /C: parameter introduces a list of characters to be accepted. Returned errorlevel value corresponds to the order of accepted character in this sequence example: Y 1, N 2, C 3. When the /C: option is not specified, default is YN ( Y 1, N 2 ). /T:C,10 set waiting time limit 10 seconds (0 99 allowed) and then, if no key is pressed, take the C choice as default (errorlevel 3 in this example). When time limit is not set, CHOICE.COM will wait indefinitely. Time

139

Chapter 6: Selected utilities for MS-DOS7


limit 0 forces to make default choice at once: thus the CHOICE.COM utility can be used to set errorlevel. Yes, No or Continue an example of a optional prompt to be displayed just before waiting time begins. If final part of line contains a group of words, not preceded by a slash, this group of words will be displayed as prompt message. Just before prompt message two more optional parameters may be specified: /S treat choice characters as case sensitive. /N don't append displayed prompt message with a list of alternative choices and with question mark. Errorlevel values, returned by CHOICE.COM, remain intact during execution of interpreter's internal commands and may be taken into account in order to affect further course of batch file interpretation. Errorlevel values can be examined in the following lines of batch file by a succession of "if errorlevel" conditions (3.15-03) or else within a FOR cycle (3.13), assigning errorlevel value to an environmental variable, for example: FOR %%Z in (1 2 3) DO if errorlevel %%Z set Err=%%Z In a similar way the FOR cycle can be used to perform conditional jumps with "GOTO L%%Z" command, but for this purpose the expected errorlevel values in parenthesis should be enlisted in reverse order. Quite different application for CHOICE.COM utility is word parsing. The word to be parsed may be, for example, a path, if you have to check writability of specified disk, existence of each directory in the path, etc. Let's assume that file CHECK.BAT contains an analyzing program, which needs the word to be presented letter-by-letter. For this purpose the CHOICE.COM utility should be used as follows: ECHO ; | Choice /S /C:;Anyword; Call Check.bat > Temp.bat Call Temp.bat Here the word to be parsed (example: Anyword) is enclosed in semicolons, which guarantee proper separation of first and last letters. Besides this, semicolons guarantee non-stop execution because of presence of redirected answer (ECHO ;) among allowable alternatives. Prompt message is represented by group of words "Call CHECK.BAT". Being sent to STDOUT, this output message will be redirected into temporary file TEMP.BAT. After execution of the first line the created TEMP.BAT file will contain the following string: Call Check.bat [;,A,n,y,w,o,r,d,;]? The second of the shown lines calls execution of the TEMP.BAT file. During this execution all letters of the word to be parsed will be presented to CHECK.BAT as its parameters (from %2 and on) and can be analyzed separately one-by-one.

140

Chapter 6: Selected utilities for MS-DOS7


Note 1: if user breaks batch execution by pressing CTRL-BREAK or CTRL-C key combinations, then CHOICE.COM utility returns errorlevel 0. Note 2: when user presses any other key instead of those expected, CHOICE.COM sends a beep signal (the 07h control symbol) to the console. Note 3: when CHOICE.COM encounters any error, it returns errorlevel 255.

6.04

COMMAND.COM command interpreter

Command interpreter COMMAND.COM is a resident program, which presents command prompt, enables execution of commands from command line and automatic execution of commands from batch files as well. File COMMAND.COM contains code of all internal commands, specified in chapter 3. COMMAND.COM gets control over PC at final booting stage, when IO.SYS interpreter executes the SHELL command (4.26) in CONFIG.SYS file. This first execution loads resident module of COMMAND.COM and arranges its primary (parent) environment with global variables. After that each next execution COMMAND.COM creates a derived (child) environment, inheriting copies of all the variables from the former (parent's) environment. Contrary to ordinary utilities, COMMAND.COM leaves no reference in its PSP (= Program Segment Prefix, A.07-1) to the parent's PSP, so the parent's environment is preserved hidden with no legal access. Repeated execution of COMMAND.COM enables to change local environmental variables and execute application files otherwise (run stepby-step, for example). Having accomplished its mission, the last loaded resident module of COMMAND.COM can be unloaded out of memory with EXIT command (3.12). Then its derived (child) environment becomes lost with all its variables, active state of the former (parent) resident module is restored, and the former (parent) environment again becomes accessible. Here is an example of loading the command interpreter, in particular, for step-by-step execution of a single batch file: Command.com C:\dos\ CON /E:1008 /L:512 /U:255 /Y /C R:\Trial.bat where: C:\dos\ an example of a path to COMMAND.COM file. This path (with final backslash!) is used to compile a value of %COMSPEC% environmental variable in the new environment. The path item should precede all other parameters. If the path is omitted, then %COMSPEC% variable will inherit its value from the parent environment. an example of device specification for I/O operations. CON stands for console, that is display for output plus keyboard for input. CON is the

CON

141

Chapter 6: Selected utilities for MS-DOS7


default device, therefore its specification may be omitted. Other device specifications (3.07) are allowed too, but the chosen device must be ready to support interactive activity of COMMAND.COM. /E:1008 optional prescription to reserve 1008 bytes of memory for environmental variables (256 32768 allowed). Default environment's size is that sufficient for all inherited variables, but not less than 160 bytes. /L:512 optional specification of internal buffer's size in bytes (128 1024 is allowed, 256 is the default). This size must be large enough for placement of command line with all substitutions of explicit values and commands. /U:255 optional specification of input buffer size in bytes (128 255 is allowed, 128 is the default). This size sets maximum length of original command line (before alias substitutions are made). /Y this option forces step-by-step interpretation of lines in batch files. When used together with /P parameter (permanent loading, see below), the /Y option is ignored. /C this optional parameter announces, that the following name is a name of a program to be executed, and that the interpreter's resident module must automatically unload itself after execution of this program. /K or /P parameters should be used instead of /C if the interpreter's resident module ought to stay loaded. The /K parameter does the same, but enables to unload resident module later with EXIT command (3.12). The /P parameter doesn't announce a name of a program, it denotes permanent loading of interpreter's resident module with EXIT command disabled. The /P parameter must be the last in command line, when COMMAND.COM is loaded for the first time with SHELL command (4.26) from a line of CONFIG.SYS file. R:\Trial.bat a name example for a file to be executed by COMMAND.COM interpreter. Name of an executable file may be specified after the /C or /K parameter, which must be the last COMMAND.COM's parameter in command line. All following parameters, if there are any, will be regarded as belonging to the specified executable file. Besides the shown parameters, COMMAND.COM interpreter accepts the following options: /MSG load error message texts into memory. In case of an error, which hinders reading of message texts from disk, this option ensures display of an adequate error message. /LOW this option forces to load command interpreter's resident module into conventional memory (below 640 kb). The /LOW parameter is used together with /P parameter for permanent loading.

142

Chapter 6: Selected utilities for MS-DOS7


/F this option prescribes to skip query on possible error(s) and to go on as in the case of user's answer "Fail". The /F parameter is active only when used together with /C parameter for execution of a single command. But the FOR command (3.13) keeps the /F parameter active over all operations of a cycle, and the CALL command (3.02) keeps it active over all operations in a secondary batch file. this option forces to display errorlevel value after execution of any utility, which returns errorlevel value.

/Z

Note 1: the /C parameter affects keyboard functions used to terminate execution of batch files (1.03). Note 2: when COMMAND.COM is loaded permanently with /P parameter, its first default task is interpretation of AUTOEXEC.BAT file, which is implied to exist in the root directory of the current disk. Note 3: when execution of AUTOEXEC.BAT is launched implicitly via the SHELL command (4.26), then the %0 parameter inside AUTOEXEC.BAT can't be used to initiate recursion. Note 4: having been loaded with /K parameter, COMMAND.COM is able to accept commands from other processes or from command file(s) via input redirection (see 2.04-02, 2.04-05, and also note 1 to part's 6.05 introduction article). Note 5: being executed, batch files (with *.BAT suffix) share a common environment with their interpreter COMMAND.COM. Ordinary executable files (with *.COM or *.EXE suffix) get a copy of that environment.

6.05

DEBUG.EXE debugger and mini-assembler

DEBUG.EXE is a specialized command interpreter (debugger), written by Tim Patterson as an instrument for creation of that operating system, which later has been bought by Microsoft and became known as first version of MS-DOS. DEBUG.EXE helps to find out and to fix errors in both program's executable code and PC's hardware settings. Capabilities of DEBUG.EXE are not limited to a set of its internal commands, because these commands enable to assemble just any machine code and to execute it at once. Of course, DEBUG.EXE is not a tool for writing complex programs; it can't compete with high-level languages. But circumstances dictate other criteria, when you can't rely on known compilers, when you have to examine something or to clear up. If you do it with DEBUG.EXE in CPU's real mode, then all AT-compatible computers obediently submit themselves at your disposal. You'll get direct access to disks, to ports, to memory and to code inside executable files. Command line for launching DEBUG.EXE may include name of a file to be loaded just at start and prepared for debugging, for example: Debug.exe Trial.com /B /S

143

Chapter 6: Selected utilities for MS-DOS7


where: Trial.com an example of a file to be examined, and all following items ( "/B /S" in this example) are regarded as options for this file (but not for debugger itself!). These options are written into file's PSP (= Program Segment Prefix) just as it is done when the file is loaded for execution by interpreter COMMAND.COM. Exact layout of the file in RAM depends on file's suffix (more about that in article 6.05-10). If the file to be loaded is not specified in command line, it may be defined and loaded later with debugger's internal commands "N" (6.05-12) and "L" (6.05-10). The retarded loading gives an opportunity to start code's layout from an arbitrary address. This is important, in particular, for assembling and debugging drivers (details in article 6.05-18). Just as COMMAND.COM interpreter, DEBUG.EXE activates command line editing keys (1.05) and accepts commands from command line. If there is any redirected input (2.04-02), DEBUG accepts it as a sequence of commands instead of commands from keyboard. This feature enables to write command sequences into textual command file(s) and then send it to DEBUG.EXE for automatic execution: Debug.exe < Cmnd_txt.scr All specifications of the code to be loaded or written may be included into such command files (examples in articles 9.02, 9.06, 9.08, 9.10). Note 1: when interpreter accepts redirected commands from a command file, it loses communication with keyboard via the STDIN channel, and hence data input can't be performed by interrupts INT 21\AH=01h, 06h, 07h, 08h, 0Ah (8.02-02, 8.02-04, 8.02-06). Because of the same reason the interpreter may hang, if there is no command to restore communication with keyboard in the last line of command file. Most often this mission is performed by the "Q" command, terminating each debugger's session. Another way to restore communication with keyboard without termination of debugger's session is shown in article 9.07-02. Note 2: an enhanced modification of DEBUG.EXE is developed by Paul Vojta. The main difference from original Microsoft's debugger is that enhanced modification is able to "understand" machine commands of modern processors. Archive Debug113.zip, containing version 1.13 (2008) of the enhanced debugger, can be downloaded from site http://www.japheth.de/dwnload4.html . If not specified otherwise, all following articles in part 6.05 are equally applicable to Paul Vojta's enhanced debugger.

144

Chapter 6: Selected utilities for MS-DOS7


6.05-01 DEBUG.EXE: commands and addresses

Having been started, DEBUG.EXE presents its "" (hyphen) prompt. It means that DEBUG.EXE is ready to accept a command. Debugger's commands consist of a one-letter or two-letter instruction name, which may be followed by parameters, separated by space(s) or by comma(s). Separators may be omitted, if their absence in any particular position doesn't cause ambiguity. DEBUG.EXE treats numbers as hexadecimal, upper and lower case letters as identical; the only exception from this rule is data comparison with SEARCH command (6.05-16). Most often the first parameter following command's name specifies a start point memory address. It may be presented in full form as a segment address and offset (for example, 1FA5:0100), or with an explicit reference to a segment register (for example, CS:0100), or in a short form as an offset only (for example, 0100). In the latter case segment will be defined by CS (Code Segment) register for "A" (Assemble), "G" (Go), "L" (Load), "P" (Proceed), "T" (Trace), "U" (Unassemble) and "W" (Write) commands; for other commands it will be defined by DS (Data Segment) register. Offset specifications less than 4 digits long are regarded as having preceding zero(s). For example, offset 100 is interpreted as 0100h. Initial segment address in all segment registers is the same, allocated by DOS on request of DEBUG.EXE in order to lay the code, which is to be debugged. This code will be written not just from the start of the allocated segment, but from a certain shifted point, defined by offset in IP (=Instruction Pointer) register. Initial setting for offset is 0100h (i.e. 256 decimal). Reserved 256 bytes at the start of allocated segment are known as PSP = Program Segment Prefix (details in appendix A.07-1). If action of debugger's command is directed to a group of bytes, then this group is defined either by its start point address and length or by start point address (segment:offset) and end point offset. Parameter, specifying size (length) of a group, is marked by preceding letter "L" for example, L20 specifies a group of 20h bytes. Sum of start offset and length must not exceed FFFFh. If a hexadecimal number in place of length specification is not preceded by letter "L", it is interpreted as end point offset inside the same segment. Separate segment specification for the end point is not allowed. Obviously, end point offset must be greater than start point offset. Having typed a command, the user initiates its execution by pressing the ENTER (or "CR") key. The simplest debugger's commands consist of nothing more than a single character and don't need much comments: Q ("Quit") terminate debugger's session, exit to DOS. ? display a list of debugger's commands.

145

Chapter 6: Selected utilities for MS-DOS7


However, the displayed list of commands presents no intelligible guidelines for their usage. All necessary guidelines are given in this book in the following articles of part 6.05. Note 1: if you have mistaken typing a command, DEBUG.EXE displays a message "Error" in the following line, and points with a ^ (caret) to the first character it is unable to "understand". Most often just this character is the cause of the error, but sometimes the cause may be a mistake in preceding part of command line. Note 2: absolute memory address is calculated as a sum of offset with segment address, multiplied by 10h (i.e. 16 decimal). If segment address is, for example, 1FA5h, and offset is 0100h, then absolute memory address will be (1FA5h x 10h) + 0100h = 1FB50h. 6.05-02 DEBUG.EXE: the "A" (= Assemble) command

The "A" command switches DEBUG.EXE to translation of assembler language instructions (see chapter 7) into executable machine code. This code is not executed at once, but rather is written into memory, thus forming a succession of machine commands. When translation is finished, the formed succession can be executed or saved in a file. Here is an example of the "A" command specification in debugger's command line: A 0100 Letter-name of the ASSEMBLE command is followed by address of a memory cell, where the first byte of the formed machine code should be written. In the shown example this start address is represented by an offset only, but it may be specified in any of allowable forms, enlisted in article 6.05-01. If segment is not specified explicitly, then it is defined by segment register CS:. Start address may be omitted at all, and then the start cell is pointed at by contents of registers CS:IP. Having accepted the "A" command, DEBUG.EXE shows full address of a memory cell, where the first byte of translated machine code will be written, and displays a blinking cursor, thus inviting you to type an assembler instruction, which should be translated. At that moment DEBUG.EXE doesn't accept commands, described in part 6.05, but accepts only assembler instructions, described in chapter 7. The user confirms an end of each assembler instruction by ENTER keystroke. DEBUG.EXE translates the entered instruction, writes its machine code into memory cell(s), and shows a new line with a new full address, inviting to type the next assembler instruction. In order to terminate translation of assembler instructions you have to ignore debugger's invitation and just press ENTER, while the line is left empty. Then DEBUG.EXE returns to normal interactive operation, shows its hyphen prompt and again becomes ready to accept commands, described in part 6.05. If DEBUG.EXE received assembler instructions from a file via input redirection, then an empty line should be left in

146

Chapter 6: Selected utilities for MS-DOS7


this file (7.01-04), and this empty line will force DEBUG.EXE to terminate translation of assembler instructions. 6.05-03 DEBUG.EXE: the "C" (= Compare) command

The "C" command shows non-coincident bytes from two successions of memory cells. Identical bytes are skipped. Command line with a call for the "C" command may look, for example, as follows: C 113 L8 153 After the letter-name "C" the first and the third parameters are start addresses of those memory cell successions, where are the bytes to be compared. Start addresses may be specified in any of their allowable forms (6.05-01). In the shown example both start addresses are represented by offsets only, and then default segment for both sequences is defined by segment register DS:. The second parameter after letter-name "C" defines either offset of the last memory cell in the first succession or the length of byte successions to be compared (if the number is marked by preceding letter "L"). In the shown example L8 means length 8 bytes. All three parameters after the "C" command are required. 6.05-04 DEBUG.EXE: the "D" (= Dump) command

The "D" command displays hexadecimal contents of a group of memory cells, and at the same time in the right part of display screen shows the same contents, represented by characters and symbols of ASCII code. Here is an example of debugger's command line with a call for the "D" command: D 19A9:02E0 L10 Just after the letter-name "D" there is a full address of the first memory cell in a group to be displayed. Address may be specified in any of allowable forms (6.05-01). If segment is not specified, then it will be defined by segment register DS:. The second parameter after the letter-name "D" defines either offset of last memory cell in a group or a length of that group (if the number is marked by preceding letter "L"). In the shown example L10 means length 10h (i.e. 16 decimal) bytes. If the second parameter is not specified, 80h bytes (i.e. 128 decimal) will be shown. If both parameters are omitted, then 80h bytes will be shown, starting from current offset, which is increased by length of the shown bytes group at each execution of the "D" command. This is why each next execution of the "D" command without parameters will show not the same, but the next group of bytes. Examples of dumps, displayed by the "D" command, are shown in fig. 8 12 (in chapter "Appendixes").

147

Chapter 6: Selected utilities for MS-DOS7


6.05-05 DEBUG.EXE: the "E" (= Enter) command

The "E" command writes new contents into one or more memory cells. Debugger's command line with a call for the "E" command may look like this: E 0211 In the shown example the letter-name "E" is followed by address (offset) of the memory cell, where writing of new data should start. When segment is not specified, then it is defined by DS: segment register. Address may be specified in any of its allowable forms (6.05-01), but it can't be omitted. Having accepted this command, DEBUG.EXE shows full address of the requested memory cell and shows the data byte, present in this memory cell at that moment. The shown line ends with a dot, which should be regarded as a prompt to type a new data byte for this memory cell. Data in ASCII codes are not accepted by "E" command via keyboard, data should be presented in a form of two hexadecimal digits per byte. Then a SPACEBAR keystroke should follow. If a new data byte has been typed in, it will be written into memory cell, but if a new byte hasn't been typed, the former contents of this memory cell is preserved. In any case DEBUG.EXE will show contents of the next memory cell, inviting to change it in the same way. If instead of the SPACEBAR keystroke the "" (minus, or hyphen) key will be pressed, then the user will be given an opportunity of another attempt to change contents of the previous memory cell. In order to terminate data input, you have to press ENTER instead of SPACEBAR. The "E" command is executed otherwise, without waiting for data input via keyboard, if new input data are specified in the same command line after the memory cell address, for example: E 03E0 'Data error' 0D 0A New input data in command line may be represented either by two hexadecimal digits per byte, or as string(s) of ASCII characters, enclosed at both sides in quotes or in double quotes. Both forms of representation may interlace in one line in arbitrary order. Before being written into memory, ASCII characters are translated into hexadecimal form byte-by-byte, except the enclosing quotes, which are not translated and are not stored. If a byte is represented by a single hexadecimal digit, it will be interpreted as the lower half-byte, for example, the "A" digit will be interpreted as 0Ah. In any case data will be written into sequential memory cells, starting from the specified address, in the order of their placement in command line. 6.05-06 DEBUG.EXE: the "F" (= Fill) command

The "F" command fills a succession of memory cells with a repeated record of a single byte or of any given sequence of bytes. In debugger's command line a call for the "F" command may look, for example, like this: F 03E0 L2E 0D 0A 'Reserved' 90 90

148

Chapter 6: Selected utilities for MS-DOS7


The first parameter after the letter-name "F" is start address of memory cell succession which is to be filled. Though start address may be specified in any of its allowable forms (6.05-01), in the shown example it is represented by an offset only, and then segment is defined by DS: segment register. The second parameter specifies either a length of memory cells succession (if the number is marked by preceding letter "L") or offset of the last cell in that succession. In the shown example length 2Eh bytes (46 decimal) is declared. The third and the following parameters represent that sequence of bytes, which should be used to fill memory cell succession. At least one byte of this sequence must be specified. Data in command line may be represented either by two hexadecimal digits per byte or by a group(s) of ASCII characters, enclosed at both sides in quotes or in double quotes. Both forms of representation may interlace in one line in arbitrary order. Before being written into memory, ASCII characters are translated into hexadecimal form byte-by-byte, except the enclosing quotes, which are not translated and are not stored. If the data, presented in command line, are not enough to fill the whole succession of memory cells, the process is repeated: the next cells are filled with a copy of the same sequence of bytes. On the contrary, if succession of memory cells is too short, filling process terminates at the last cell without error message. 6.05-07 DEBUG.EXE: the "G" (= Go) command

The "G" command initiates execution of machine code commands, prepared in memory beforehand. Here is an example of debugger's command line with "G" command: G =100 143 Optional parameters following letter-name "G" are addresses. The first address, preceded by equality sign, points at the first byte of that machine command, which is to start the execution procedure. Though start address may be specified in any of its allowable forms (6.05-01), in the shown example it is represented by offset only; hence, default segment will be defined by CS: segment register. If an address, marked by preceding equality sign, in not present in command line, then the start memory cell will be pointed at by contents of CS:IP registers. Those addresses, which are not preceded by equality sign, are breakpoints. Up to 10 breakpoints may be specified in command line for different branches of the program under test. In those memory cells, which are pointed at by breakpoints, DEBUG.EXE replaces original machine code by code CCh of INT 03 interrupt (8.01-04). Interrupt INT 03 handler returns control back to DEBUG.EXE, and then debugger restores original machine code in breakpoint memory cells, and also stores the state of registers and flags, thus preparing further continuation of debugging procedure. For successful termination of the described operations two conditions must be met. First, breakpoint address(es) must correspond to first byte(s) of machine command(s), since

149

Chapter 6: Selected utilities for MS-DOS7


otherwise the CCh code will be interpreted not as INT 03 call, but as a part of previous machine command. Second condition is that execution shouldn't be stopped in any other way, besides the prepared breakpoints, because otherwise DEBUG.EXE will not store states of registers and flags, will not restore the replaced contents of memory cells, and the program under test will become corrupted. You'll have nothing to do but reload it with "L" command (6.05-10). If you have no intention to apply breakpoints, there are two methods to stop execution, initiated by the "G" command. The first is a call for INT 21\AH=4Ch handler (8.02-55), which stops execution, terminates debugger's session and returns control back to DOS. The second method is a call for INT 20 handler (8.02-01), which stops execution, but doesn't terminate debugger's session. The RET command (7.03-73) at original stack's position also induces a INT 20 call with the same consequences. DEBUG.EXE gets control back and begins to accept next command(s) either from keyboard or from redirection according to the way it was launched. After a stop of execution via a INT 20 call the code under test most probably wouldn't be corrupted, but final states of registers and flags will be lost. 6.05-08 DEBUG.EXE: the "H" (= Hexadecimal) command

The "H" commands calculates and displays a sum and a difference of two hexadecimal numbers, each of up to four digits long. In debugger's command line it may look like this: H 12BA 00AE In the shown example two parameters after letter-name "H" are original numbers presented for calculation. Any of them or both may comprise less than four digits, and then zero(s) in senior positions will be implied. Presence of both parameters is required. 6.05-09 DEBUG.EXE: the "I" (= Input) command.

The "I" command reads a byte from the specified port and shows it on the screen. The shown byte can't be written elsewhere or stored. A single parameter in command line after the letter-name "I" is port address, for example: I 03f8 Unlike ordinary memory addresses, port addresses have no relation to segments and segment registers. Port address is just a hexadecimal number of up to four digits long. Zeros in senior positions may be omitted. Addresses of several common ports are enlisted in appendix A.14-1.

150

Chapter 6: Selected utilities for MS-DOS7


6.05-10 DEBUG.EXE: the "L" (= Load) command

The "L" command reads a succession of codes from disk and loads it into memory, starting from specified address and on. Succession of codes to be read may be defined either by a name of a file or by a number of disk's sector. Here is an example of "L" command usage for loading a succession of codes from a file: L 0100 Single parameter in the shown example is a memory cell address, where writing of code succession should start. Address may be specified in any of its allowable forms (6.05-01), but when segment is omitted, it is defined by CS: segment register. It is assumed, that the name of a file to be read is written already into PSP (A.07-1) by "N" command (6.05-12) or was initially transferred there from parameter of that command line, which has launched the debugger. Moreover, it is assumed, that contents of DS: segment register has not been changed since this name was written into PSP, and hence the "L" command can still refer to segment address in DS: for reading this name from PSP. Address after the letter-name "L" may be omitted, and then succession of codes will be loaded from address CS:0100 an on, except loading from files with suffixes *.EXE and *.HEX. These files contain a header with supplementary loading specifications. Supplementary offset from the header of *.HEX files is added to that taken by default (0100h) or to that specified after the "L" command. For *.EXE files the offset specified after the "L" command is ignored, header of the *.EXE files is not loaded. In order to see "as they are" those files loaded without a header or not loaded at all, their suffix should be replaced (preferably with *.BIN). In any case length of the file is stored in CX register. If length exceeds 64 kb, then senior digits of length are written into BX register. For loading a succession of codes from sectors of logical disk, command line must contain four required parameters, for example: L 0100 2 0 1 The first parameter, just as in previous example, is address of that memory cell, where writing of code succession should start. The second parameter is interpreted as logical disk number: 0 disk A:, 1 disk B:, 2 disk C:, and so on. The third parameter represents actual hexadecimal number of the first sector to be read, the fourth parameter total hexadecimal number of sectors to be read. Up to 80h sectors can be read in one operation. In particular, the shown example specifies reading of a single sector number 0 (the bootsector) from logical disk C: and writing its contents into memory starting from address CS:0100. Contrary to loading from files, loading from disk's sectors doesn't induce writing of loaded succession's length into registers. Physical disk's sectors beyond logical disk(s) are not accessible to "L" command.

151

Chapter 6: Selected utilities for MS-DOS7


6.05-11 DEBUG.EXE: the "M" (= Move) command

The "M" command copies a block of data from one place in memory into another. In debugger's command line a letter-name "M" must be followed by three required parameters, for example: M 0100 L20 0180 In the shown example the first parameter specifies start address of the source data block, and the third parameter a similar start address of the target memory space. Both these addresses may be specified in any of their allowable forms (6.05-01). If address is represented by offset only, then segment is defined by DS: segment register. The second parameter in command line represents either the length of the source data block (if the number is marked by preceding letter "L") or offset of its final byte. In the shown example second parameter L20 denotes length 20h bytes (32 decimal) of the source data block. If the source data block and target memory space are not superimposed, then data in the source block remain unchanged. But when target memory space overlaps source data block, data in the overlapped part of this block will be overwritten without error message. In any case the order of copying is chosen so that the bytes to be overwritten are copied first. 6.05-12 DEBUG.EXE: the "N" (= Name) command

The "N" command declares a name of a file, which is to be loaded later by "L" command (6.05-10) or written later by "W" command (6.05-19). Letter-name "N" must be followed by a name of a file, for example: N Trial.com /S /D If suffix of the specified name exists, it can't be omitted. Name of a file may be preceded by a path and may be followed by a group of parameters (as "/S /D" in the shown example). All data, declared by the "N" command, are written into PSP area (A.07-1) at address DS:0081 and on. Besides that, length of the written string is stored at DS:0080, file's name without suffix at DS:005D, suffix at DS:0065. As far as the mentioned addresses refer to DS: segment register, its contents must not be changed up to the moment when the written data will be requested by "L" or by "W" command. When the "N" command is executed without parameters, it overwrites data in DS:005C DS:0080 memory cells and writes code 0Dh in memory cell DS:0081. Note 1: initial settings in CS: and DS: registers are the same. Therefore loading of the program under test below default address CS:0100 may cause overwriting of PSP data (A.07-1), including the stored filename(s). Moreover, loaded code itself may be damaged later because of writing data into PSP by "N" command.

152

Chapter 6: Selected utilities for MS-DOS7


6.05-13 DEBUG.EXE: the "O" (= Output) command

The "O" command sends a data byte into specified port. Letter-name "L" in debugger's command line must be followed by two parameters, for example: O 0378 00 The first parameter represents port address, the second parameter is the byte to be sent. Unlike ordinary memory addresses, port addresses have no relation to segments and segment registers. Port address is just a hexadecimal number of up to four digits long. Zeros in senior positions may be omitted. Addresses of several common ports are enlisted in appendix A.14-1. Note 1: incautious usage of the "O" command may affect important PC's settings and cause serious malfunctioning. 6.05-14 DEBUG.EXE: the "P" (= Proceed) command

The "P" command initiates execution of a prescribed number of machine instructions, prepared or loaded into memory beforehand. If execution is initiated by the "P" command, then loops (7.03-55 7.03-57), subroutine calls (7.03-08), repetitions (7.02-03, 7.02-04) and interrupts (7.03-28) are not traced step-by-step, but rather are executed as though it were one machine instruction. This feature is the main difference between "P" and "T" (6.05-17) commands. Debugger's command line with "P" command may look like this: P =0100 5 The first parameter after letter-name "P" is address of machine instruction, intended to start execution. This address may be specified in any of its allowable forms (6.05-01), but it must be preceded by equality sign. If address is represented by offset only, as in the shown example, then default segment is defined by CS: segment register. The second parameter specifies the number of machine instructions to be executed. Both parameters may be omitted, and then only one instruction will be executed, the one pointed at by CS:IP. After execution of machine instructions the "P" command displays current states of registers and flags, and also presents result of unassembling the next, not executed yet machine instruction. Note 1: the "P" command shouldn't be applied to machine instructions, which are read directly from fixed storage chips or from read-only memory (ROM). For such purposes the "T" command (6.05-17) should be used instead.

153

Chapter 6: Selected utilities for MS-DOS7


6.05-15 DEBUG.EXE: the "R" (= Register) command

If you type into command line a single letter R and press ENTER, then DEBUG.EXE will show you current states of CPU's main registers and flags. Typical initial states of registers and flags, set by DEBUG.EXE at the moment when it is launched, are shown below in fig.1.

Fig 1
Let's notice, that in all shown segment registers (DS, ES, SS, CS) the same hexadecimal number is written: it is segment address of memory space, allocated by DOS for debugging experiments. Other registers and flags acquire predetermined initial states. Bi-letteral designations of flag's initial states have the following meaning: NV No oVerflow; UP count UP, or incremental calculation of offsets; EI Enable Interrupts; PL Positive number; NZ Non-Zero value or inequality; NA No Auxiliary carry in the 4-th digit position; PO Parity Odd, odd sum of bits in least significant byte; NC No Carry in most significant digit position. The last line of displayed message (fig.1) shows machine instruction code in memory cell, pointed at by CS:IP, together with unassembled representation of that code. Just this machine instruction will be executed, if DEBUG.EXE will be given "T" (6.05-17) or "P" (6.05-14) command with default parameters. You may get an opportunity to change flag's states, if letter-name "R" in debugger's command line will be followed by parameter "F": R F DEBUG.EXE responds to this command by showing current flag's states together with a hyphen, which is an invitation to input bi-letteral designations of desired flag's states. Flag's states, opposite to those shown in fig.1, can be set by typing the following input: OV OVerflow after arithmetic operation; DN count DowN, or decremental calculation of offsets; DI Disable Interrupts; NG NeGative number; ZR ZeRo value or equality; AC Auxiliary Carry in the 4-th digit position;

154

Chapter 6: Selected utilities for MS-DOS7


PE CY Parity Even, even sum of bits in least significant byte; CarrY in most significant digit position.

The order of flag's states input is indifferent. If new state for some flags is not specified, those flags preserve their former state. In order to get an opportunity to change a state of a register, letter-name "R" in debugger's command line must be followed by a name of that register, for example: R AX The shown command opens the AX register for writing new value. The "R" command also enables to open registers BX, CX, DX, BP, SP, DI, SI, CS, DS, ES, SS, IP (and PC it is another name for the same IP register). Having got the shown command, DEBUG.EXE displays former contents of that register and a colon, thus inviting you to input new value of up to four hexadecimal digits long. If you wouldn't type new data and just press ENTER, the former value in this register will be preserved. The "R" command doesn't provide separate access to senior byte and to least significant byte of 16-bit registers, for example, to AH and to AL inside the AX register. If you want to change the state of only one byte, you have to specify unchanged former value for the other byte of the same register. Note 1: the 8 flags, mentioned in this article, are not all the flags in modern CPU's. For a more complete list of flags see appendix A.14-4. 6.05-16 DEBUG.EXE: the "S" (= Search) command

The "S" command performs a search for a specified sequence of bytes throughout a limited search region. Both sequence of bytes and search region must be defined by parameters, following the "S" command in debugger's command line, for example: S 0100 L200 20 'st' The first parameter after the letter-name "S" is start address of search region. Though start address may be specified in any of its allowable forms (6.05-01), in the shown example it is represented by an offset only, and then default segment is defined by DS: segment register. The second parameter specifies either a length of search region (if the number is marked by preceding letter "L") or offset of the last cell of that region. In the shown example length 200h bytes (512 decimal) is declared. The third and all the following parameters represent that sequence of bytes, which is to be searched for. At least one byte of this sequence must be specified. Bytes of the sequence may be represented either by two hexadecimal digits per byte or by a group(s) of ASCII characters, enclosed at both sides in quotes or in double quotes. Both forms of representation may interlace in one line in arbitrary order. Before being taken into account, ASCII characters are translated into hexadecimal form byte-by-byte,

155

Chapter 6: Selected utilities for MS-DOS7


except the enclosing quotes, which are not included in the prepared sequence sample. In the course of search similar letters in upper case and in lower case will be considered different. When the search is finished, DEBUG.EXE shows all addresses in the search region, where the sought sequence has been found. It's important to notice, that DEBUG.EXE doesn't analyze the mission of the found bytes sequence(s). Data strings and machine instructions may include just the same sequences of bytes. Solving of such uncertainties is a user's prerogative. 6.05-17 DEBUG.EXE: the "T" (= Trace) command

The "T" command initiates execution of a prescribed number of machine instructions, prepared or loaded into memory beforehand. The "T" command can trace execution of machine instructions inside loops, subroutine calls, interrupt handlers, etc. This feature is the main difference between "T" and "P" (6.05-14) commands. Here is an example of debugger's command line with "T" command: T =0100 5 The first parameter after letter-name "T" is address of machine instruction, intended to start execution. This address may be specified in any of its allowable forms (6.05-01), but it must be preceded by equality sign. If address is represented only by offset, as in the shown example, then default segment is defined by CS: segment register. The second parameter specifies number of machine instructions to be executed. Both parameters may be omitted, and then only one instruction will be executed, the one pointed at by CS:IP. After execution of machine instructions the "T" command displays current states of registers and flags, and also presents result of unassembling the next, not executed yet machine instruction. Note 1: as far as the "T" command traces execution of machine instructions inside loops, subroutine calls and interrupt handlers, it may involve very long sequences of instructions, taking too much time to trace. In such cases the "P" command (6.05-14) should be preferred. 6.05-18 DEBUG.EXE: the "U" (= Unassemble) command

The "U" command displays assembler instructions obtained by translation of executable machine code from a group of memory cells. A debugger's command line with "U" command may look like this: U 014B L10 The first parameter of the "U" command is an address of the first memory cell in selected group. Address may be specified in any of its allowable forms (6.05-01). If

156

Chapter 6: Selected utilities for MS-DOS7


segment is not specified, then it is defined by CS: segment register. The second parameter after the letter-name "U" defines either offset of the last memory cell in selected group or a length of that group (if the number is marked by preceding letter "L"). In the shown example L10 means length 10h (i.e. 16 decimal) bytes. If parameters are omitted, then code of 20h bytes will be translated, starting from current offset inside CS: segment. Current offset is increased by length of the translated bytes group at each execution of the "U" command, so that each next execution of the "U" command without parameters shows translation of code from not the same, but from the next group of memory cells. It's important to notice, that the "U" command can't discriminate between executable code and other data, can't find the first byte of long machine instructions. When specified start address doesn't correspond to the first byte of instruction, or when unassembling is applied to data, then translation produces garbage. Two examples of unassembling are shown below in fig.2: the first corresponds to proper specification of start address (0181h), the other shows consequences of improper specification.

Fig. 2
In case of improper start address specification (0180h) translation of bytes at offsets 0180h and 0184h produces invalid results, but after that the "phase" of unassembling comes to a proper steady state. If translated machine instructions are correct and are known to DEBUG.EXE, then stochastic process of reaching the proper steady state usually takes up to 10h bytes and doesn't affect further translation. Of course, commands should be unassembled just as they are apprehended by processor. However, the same machine code may be interpreted in different ways. One reason of differences is that machine codes of short jump instructions don't comprise jump target address, but rather contain a target offset relative to current contents of IP register. Debugger calculates target addresses by addition of these offsets to IP register contents. The latter depends on start offset, where the first byte has been loaded of that code, which is to be unassembled. Therefore unassembling of short jump instructions can't be

157

Chapter 6: Selected utilities for MS-DOS7


performed correctly, unless the code, which is to be unassembled, is loaded just as it must be loaded for execution, i.e. starting at CS:0000 address for drivers and at CS:0100 address for programs with suffixes *.COM and *.EXE. Another reason of differences between processor's and debugger's interpretations of machine codes is the effect of processor's type and state. Interpretation depends on operand size byte in code segment descriptor (note 5 to A.12-2). Besides that, there are several machine codes, which are interpreted in a special manner by 64-bit processors. However, proper processor's type and state for a particular presented machine code isn't "known" to DEBUG.EXE. It is able to unassemble those machine codes only, which are designed for 16-bit execution. There is no sense in forcing DEBUG.EXE to unassemble other machine codes. Invalid results of unassembling may be caused by those machine instructions, which are not "known" to debugger. Because of this reason Microsoft's version of DEBUG.EXE can't be recommended for unassembling modern programs. Another version of DEBUG.EXE, proposed in note 2 to part's 6.05 introduction article, should be preferred. Of course, recent versions of "respectable" unassemblers (IDA, SoftICE, etc.) are much more "clever", but can't give comparable freedom of access and even can't work under DOS. For those constrained to use Microsoft's version of DEBUG.EXE some "unknown" machine codes are given in the table below. Its first column presents first bytes of machine codes, which are shown by DEBUG.EXE as parameters of DB command (7.01-01) in a separate line. First byte together with second byte, given in the second column, are often enough to understand the type of operation. If necessary, names and references from the fourth column enable to find more information about particular instruction(s). First byte 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 0F 60 Second byte 00 01 02 03 05 2(03) 4(0F) 8(0F) 9(0F) A(0,8) A(1,9) A2 A(47) B(2,4,5) Data bytes 13 13 13 13 13 2 Operation, instruction loading of task register (LTR) appeals to registers GDTR, IDTR, MSWR load access rights (LAR) load segment limit (LSL) loading of system registers (LOADALL) MOV CR, MOV DR (note 1 to 7.03-58) conditional copying (CMOV) conditional jumps inside one segment bit's conditional set/reset (SET) PUSH FS, PUSH GS (7.03-69) POP FS, POP GS (7.03-67) identification of CPU (CPUID) double word shift (SHLD, SHRD) load segment registers (LSS, LFS, LGS) copying of AX DI into stack (PUSHA)

12 02

158

Chapter 6: Selected utilities for MS-DOS7


Continuation of table 6.05-18 61 62 3 63 2 6(4,5) 66 67 6(8,A) 12 6(9,B) 13 6(C,D) 6(E,F) 8(C,E) E(0F) C(0,1) E(07) 1 C(0,1) E(8F) 1 6.05-19 popping stack data into AX DI (POPA) check of array's bounds (BOUND) adjustment of access rights (ARPL) segment prefixes FS:, GS: (7.02-01) operand size prefix (7.02-06) address size prefix (7.02-07) push a number into stack (PUSH, 7.03-69) multiplication (IMUL, note 1 to 7.03--25) group input from port (INSB, INSW) group output into port (OUTSB, OUTSW) MOV FS, MOV GS (note 2 to 7.03-58) SHL bl,0f, SHL bx,0f (7.03-82) SHR bl,0f, SHR bx,0f (7.03-83)

DEBUG.EXE: the "W" (= Write) command

The "W" command copies a code's succession from PC's memory onto a logical disk, either in a form of a file or just into disk's sectors. Here is an example of "W" command usage for writing a succession of codes into a new file: W 0100 A single parameter in the shown example is a memory cell address, where reading of code succession should start. Address may be specified in any of its allowable forms (6.05-01), but when segment is omitted, default segment is defined by CS: segment register. If address is not specified, reading of code succession starts at CS:0100. Length of code succession, counted from start address, must be prepared beforehand: least significant two bytes of length in CX register, most significant byte in BX register. It is assumed, that name of new file to be created is written already into PSP (A.07-1) by "N" command (6.05-12). The name may have any suffix except *.HEX and *.EXE, because DEBUG.EXE is unable to compile a header for such files. One more assumption is that contents of DS: segment register has not been changed since name of new file was written into PSP, and hence the "W" command can still refer to segment address in DS: for reading this name from PSP. If the prepared name is not preceded by a path, new file will be created in the current directory. If a file with the same name exists yet, it will be overwritten without error message. For writing into sectors of a logical disk the letter-name "W" must be followed by four required parameters, for example: W 0100 0 0 1 Here the first parameter presents start address of code succession, just as in previous example of writing into a file. The second parameter is interpreted as logical disk number:

159

Chapter 6: Selected utilities for MS-DOS7


0 disk A:, 1 disk B:, 2 disk C:, and so on. The third parameter represents actual hexadecimal number of the first sector to be written, the fourth parameter total hexadecimal number of sectors to be written. Up to 80h sectors may be written in one operation. Total number of sectors defines the length of written code succession, contents of CX and BX registers are ignored. In particular, the shown example specifies writing of a single sector number 0 (the boot-sector) onto logical disk A:. Physical disk's sectors beyond logical disk(s) are not accessible to the "W" command. Note 1: when it is necessary to write a code succession from PSP region (A.07-1) into a file, you can't declare file's name by "N" command before a spare memory space for writing file's name is prepared. This may be done either by moving code succession out of PSP memory region or by changing DS: segment register contents so that file's name wouldn't overwrite code succession in PSP (example in article 9.08). 6.05-20 DEBUG.EXE: the "XA" (= Allocate) command

The "XA" command appeals to EMM386.EXE memory manager (5.04-02, 8.03-59) with a request to allocate a specified memory space beyond conventional memory and to assign a hexadecimal reference number a handle to the allocated memory space. Requested operation can't be performed unless the EMM386.EXE memory manager is loaded yet and unless memory above 1088 kb is available. In debugger's command line the name "XA" must be followed by requested number of logical memory pages of 16 kb each, for example: XA 1A The shown requested memory space is 1Ah (26 decimal) logical pages, which will be enumerated from 00h to 19h. DEBUG.EXE responds to the request with a message, for example, "Handle created 0006". Hence, the allocated memory space can be referenced with hexadecimal number 0006h. But this is not enough for access to the allocated memory space, one more operation must be performed: a limited number of selected logical pages from the allocated memory space must be mapped onto physically addressable memory space by "XM" commands (6.05-22). 6.05-21 DEBUG.EXE: the "XD" (= Deallocate) command"

The "XD" command appeals to EMM386.EXE memory manager (5.04-02, 8.03-61) with a request to deallocate a particular memory space, which has been allocated yet by "XA" command (6.05-20). It is assumed, that EMM386.EXE memory manager is loaded and that memory beyond 1088 kb is available. In debugger's command line the name "XD" must be followed by a hexadecimal reference number (a handle), identifying the memory space, which is to be deallocated, for example:

160

Chapter 6: Selected utilities for MS-DOS7


XD 0006 DEBUG.EXE responds to the shown example: "Handle 0006 deallocated". Since that moment the 0006h handle becomes invalid, access to logical pages in deallocated memory space is lost, and this space is regarded as free. 6.05-22 DEBUG.EXE: the "XM" (= Map) command

The "XM" command appeals to EMM386.EXE memory manager (5.04-02, 8.03-60) with a request to map a 16 kb logical page in allocated memory space onto a "physical" page of the same size. Here the term "mapping" means adjustment of address translation mechanism in CPU so that ordinary 16-bit addresses within "physical" page address space are translated by CPU into 32-bit addresses of real memory cells in that part of address space, which corresponds to specified logical page. It is assumed, that PC has a 32-bit CPU, that amount of memory exceeds 1 Mb, that EMM386.EXE memory manager is loaded yet and that reference number (a handle) is assigned yet to the allocated memory space by "XA" command (6.05-20). In debugger's command line the name "XM" must be followed by three required parameters, for example: XM 0B 03 0006 The first parameter 0Bh in the shown example is a number of requested logical page in allocated memory space. The second parameter 03h in the shown example is a number of "physical" page. The third parameter is a reference number (a handle), which is assigned to that allocated memory space, where the requested logical page belongs. Numbers of "physical" pages may be selected from 00h to 1Bh, but it should be taken into account, that "physical" pages from 04h and on occupy address space in conventional memory. This is why the most actively used are "physical" pages 00h 03h, which by default correspond to segment addresses E000h, E400h, E800h and EC00h accordingly. But their placement in address space may be affected by PC's BIOS requirements and by EMM386.EXE (5.04-02) memory manager's settings. Therefore in each particular case placement of "physical" pages should be checked by the "XS" command (6.05-23) or by a call to INT 67\AX=5800h handler (8.03-70). 6.05-23 DEBUG.EXE: the "XS" (= Show) command

The "XS" command appeals to EMM386.EXE memory manager (5.04-02, 8.03-70) with a request to display data, related to memory usage and to placement of "physical" pages. It is assumed, that PC's amount of memory exceeds 1 Mb and that EMM386.EXE memory manager is loaded yet. Since "XS" command needs no parameters, command line with "XS" command looks like this:

161

Chapter 6: Selected utilities for MS-DOS7


XS DEBUG.EXE responds to "XS" command with display of a table showing valid reference numbers (handles) and how many logical pages is associated with each handle. Then segment addresses are shown for each "physical" page. The last lines display statistics: total number of logical pages, number of free logical pages, maximum available number of handles and a number of handles, which are assigned yet. However, displayed table will be too long and wouldn't fit the screen, if it will comprise data about all 28 "physical" pages, stipulated by EMS 4.0 specification. In order to see the whole length of the table, you may either redirect output into a file (2.04-03), or set video mode 108h (A.10-1), or else limit actual number of "physical" pages by means of EMM386.EXE driver's settings (5.04-02).

6.06

DISKCOPY.COM diskette copying utility

DISKCOPY.COM copies the whole contents of one floppy disk onto another, including volume label and serial number. Both floppies (diskettes) must be of the same type. Here is an example of command line for copying a diskette in a PC equipped with two floppy drives: DISKCOPY.COM A: B: /V where: A: B: /V letter-name example of a drive with source diskette; letter-name example of a drive with target diskette; optional prescription to verify the copy.

Besides the shown options, DISKCOPY.COM can accept also /1 prescription to copy one side only of a diskette (for obsolete diskettes with a single writable side). /M prescription to perform multi-pass copying via memory, when one floppy drive only is available and a buffer-file on a HDD shouldn't be arranged. If computer is equipped with only one floppy drive, then the same letter-name must be specified both for source and for target. In this case DISKCOPY forms a temporary buffer-file on a HDD in a directory, specified by environmental variable %TEMP%, then suggests to replace the source diskette with target diskette, and copies data from buffer-file onto target diskette. After that buffer-file is automatically deleted. But when the %TEMP% variable is not defined (or when /M option is specified), the source diskette is partially copied into available memory space, and therefore you'll have to exchange source and target diskettes several times in the same floppy drive.

162

Chapter 6: Selected utilities for MS-DOS7


DISKCOPY.COM is not designed to create a non-temporary file-image of a diskette. Besides that, DISKCOPY.COM can't cope reasonably with damaged sectors. Because of these drawbacks nowadays other copying programs are preferred. For example, the IMG.EXE utility can be recommended. Archive file IMG.ARJ, comprising the IMG.EXE utility, can be downloaded from server ftp://ftp.elf.stuba.sk/pub/pc/utildisk/ . Note 1: DISKCOPY.COM and similar diskette copying utilities can't be applied to hard disk drives, to network drives, to CD/DVD-ROMs and also to virtual disks, arranged by utilities ASSIGN.COM, JOIN.EXE and SUBST.EXE.

6.07

DOSKEY.COM command line manager

DOSKEY.COM is a resident supplement to command line functions of COMMAND.COM interpreter. DOSKEY.COM enables to edit command line text, to recall former commands, to create and execute macrocommands, comprising simple sequences of operations. Procedures, specified via macrocommands, become available after loading of their definitions by DOSKEY.COM into special memory buffer. Besides this buffer, resident module of DOSKEY.COM occupies about 4 kb. DOSKEY.COM in MS-DOS7 has been changed relative to its former versions: it has been given an ability to load a list of macrocommand's definitions from a textual file and to increase sizes of both keyboard buffer and command line editing buffer. DOSKEY.COM can be loaded from command line or from a line of a batch file (AUTOEXEC.BAT or other), either directly or with LH command (3.17), for example: LH Doskey.com /bufsize:1024 /insert /file:C:\DOS\MS7\Macro.scr where: /bufsize:1024 macrocommand buffer's size definition (minimum is 256 bytes, default is 512). This option should be used when DOSKEY.COM is loaded for the first time or is reloaded with /reinstall option (see further). Free part of the same buffer is used to store previous command lines (the history). /insert turns command line into character insertion mode, enabling to insert each next character between those typed earlier. Default is overstrike mode, when next characters replace the former ones. /file:C:\DOS\MS7\Macro.scr is a specification example for loading macrocommand's definitions from a textual file (an example of such file is given further). The path, preceding filename, may be omitted, if this file exists in the current directory. Filename and suffix of this file are arbitrary, but if suffix exists, it must be specified. Other options, allowable for loading operations, are: /echo:off disable display of executed macrocommands on the screen.

163

Chapter 6: Selected utilities for MS-DOS7


/keysize:31 increase size of keyboard's type-ahead buffer (default is 15 bytes). /line:256 set size of a buffer for editing command line (default is 128 bytes). /reinstall install a new resident module of DOSKEY.COM. This may be needed in order to change buffer's size or in order to revive functions, lost because of interference with other TSR utilities. Each reinstallation increases amount of occupied memory by about 4 kb (since former resident module of DOSKEY.COM can't be unloaded). When DOSKEY.COM is loaded yet, it may be called again with /H option in order to show stored previous commands (the history): Doskey /H or else with /M option in order to show stored macrocommands: Doskey /M Besides this, DOSKEY.COM may be called again in order to load one more definition of a macrocommand into memory buffer from command line, for example: Doskey count=C:\DOS\COM\Find.exe /v /c "" $1 Here the word "count" is interpreted as a name of new macrocommand. This name, being typed into command line close to command prompt, will initiate execution of command(s), specified within macrocommand's definition to the right of equality sign. The shown definition consists of one command, which counts lines in any textual file, represented here by dummy parameter $1. In the course of macrocommand's execution dummy parameter is replaced by actual filename, specified after macrocommand's name in the same command line. Commands within macrocommand's definition may contain equality signs and substitutions of variable's values (such as %Temp%). When symbol "$" is encountered within macrocommand's definition, it is interpreted together with the following letter (or digit) in a special way as: $G output redirection sign ">" (right arrow); $L input redirection sign "<" (left arrow); $B intermediate redirection sign "|" (the "pipe"); $T a separator between commands within one macrocommand; $1-$9 dummy parameters, equivalent to %1 %9 in batch files; $* all words following macrocommand's name on command line; $$ one character "$" (dollar sign). Textual file for loading macrocommand's definitions must contain one definition per line, which may look, for example, as follows: count=C:\DOS\COM\Find.exe /v /c "" $1 newbat=echo @echo off$G %Temp%\New.bat $T Edit.com %Temp%\New.bat

164

Chapter 6: Selected utilities for MS-DOS7


You may delete any loaded macrocommand from buffer by specifying its name followed by nothing more than equality sign, for example: Doskey count= When DOSKEY.COM is loaded, it activates the following "hot" keys: Left and right arrows CTRL-left arrow CTRL-right arrow HOME END INS ESC ALT+F10 F7 PageUp PageDown UP and DOWN arrows F9 Alt+F7 F8 shift cursor to the left and to the right shift cursor to the left by one word shift cursor to the right by one word shifts cursor to the beginning of command line shifts cursor to the end of command line toggles overstrike and insert keyboard modes clears current command line deletes all macrocommands from memory buffer displays a list of previous commands (the history) recalls the oldest line from the history list recalls the newest line from the history list shift command's selection along history list selects a command from history list by number clears list of previous commands (the history) appends character(s) in command line with the rest part of command's name, if suitable name is present in history list.

Note 1: macrocommand wouldn't be executed, if its name in command line is preceded by at least one space. Note 2: when macrocommand is synonymous to a command, it disables the latter (macrocommand will be executed instead). Note 3: DOSKEY.COM is NOT compatible with TSR file managers (Norton Commander, Volcov Commander, etc). File managers usually are preferred.

6.08

DELTREE.EXE directories eraser

DELTREE.EXE is an extremely dangerous utility, because it enables to delete directories with all their subdirectories and files, regardless to file's attributes. Only root directories of logical disks can't be deleted with DELTREE.EXE. An example of its usage may look like this: Deltree /Y C:\TEMP\TDIR1 where: /Y an option, prescribing to delete without prompts and confirmations.

165

Chapter 6: Selected utilities for MS-DOS7


C:\TEMP\TDIR1 an example specification of a directory to be deleted. There may be several such specifications in one line, but wildcards are not allowed.

6.09

EDIT.COM editor utility

EDIT.COM is a popular double-window editor program mainly for textual files, but also with limited capabilities for editing binary files. EDIT.COM enables to keep open up to ten files simultaneously. Fig.3 shows two different files opened in separate windows of EDIT.COM editor.

Fig. 3

The file(s) to be edited may be as large as PC's memory allows. EDIT.COM arranges a clipboard, enabling to send selected parts of text between opened files. Besides that, EDIT.COM is able to cooperate with mouse device drivers, thus making editing much easier and faster. The EDIT.COM editor may be launched from command line without parameters, and then it will show an empty window. The user will have to open file(s) to be edited via menu "FILE". Otherwise the file(s) to be edited may be specified just in command line, for example: Edit.com C:\DOS\Addons.txt Part6.txt Name of the first file to be edited is preceded by a path; without a path the EDIT.COM editor can open those file only, which are present in the current directory. Thus, the second file (Part6.txt), specified without path, must be present in the current directory. By default

166

Chapter 6: Selected utilities for MS-DOS7


both files will be opened for textual editing, but only the first opened file will be shown in displayed editor's window. The user is given an opportunity either to open second window by CTRL-F6 keystroke or to switch the initial window with F8 keystroke to editing of the second opened file. Some presets and help texts for EDIT.COM are stored in files EDIT.INI and EDIT.HLP (implied to be present in the same directory), but EDIT.COM can cope without help and with default settings only. When EDIT.INI is absent, the user is still allowed to save optional presets via the OPTIONS menu, and this will induce EDIT.COM to regenerate EDIT.INI file anew. EDIT.COM preserves functions of some "hot" keys, which were active in DOS. Among these are the BACKSPACE key and combinations of ALT keystroke with digit(s) in numerical keypad, enabling to enter characters by their ASCII code. But most other "hot" key functions are redefined. The ALT keystroke makes active literal "hot" keys for selecting items in upper bar menu, and also makes active digit keys in literal part of keyboard for selecting opened files by their number, if more than one file is opened. Arrow keys shift cursor anywhere inside editor's window. If the SHIFT key is kept pressed while cursor is shifted over a part of text, then this part of text becomes selected (highlighted) for being deleted or copied into clipboard. The same effect is achieved when cursor is dragged over a part of text by mouse, while its left button is kept pressed. Besides the mentioned key functions, EDIT.COM activates the following "hot" keys and key combinations: CTRL C CTRL F4 CTRL F6 CTRL F8 CTRL Home CTRL End CTRL P CTRL-PageDown CTRL-PageUp CTRL Q CTRL-Space CTRL V CTRL W CTRL X CTRL Y copies selected part of text into clipboard (CTRL-INS key combination acts similarly); closes active window (if both windows are opened); splits window in two (if one window only was opened); resizes both windows (if both windows are opened); shifts cursor to the start of opened file; shifts cursor to the end of opened file; enables to insert non-literal symbols of ASCII code (further prompt is shown in the bottom line); shifts window by line's length to the right; shifts window by line's length to the left; access to find/replace/delete functions (further prompt is shown in the bottom line); deletes selected part of text; pastes clipboard's contents into cursor's position; scrolls the text one line down (key combination CTRL-UpArrow acts similarly); cuts selected block of text into clipboard buffer; deletes the line, pointed at by cursor, even if this line is

167

Chapter 6: Selected utilities for MS-DOS7


not selected; scrolls the text one line up (key combination CTRL-DownArrow acts similarly); deletes one character at cursor's position, if no text is selected, otherwise deletes selected part of text; finds next item, specified beforehand via CTRL-Q-F key combination; toggles active and passive windows (if both are opened); switches active window to display of the next file (if several files are opened); shifts the displayed text one page up; shifts the displayed text one page down.

CTRL Z Delete F3 F6 F8 PageUp PageDown

Several "hot" key combinations are shown in upper bar menus. These menus and separate items in these menus can be opened not only with keystrokes, but also with mouse's left button as well. As far as binary files have no line structure, line wrapping specification in command line will make their editing more convenient, for example: Edit.com /78 Sc_sct.dat where /78 an option for wrapping lines to 78 characters wide. Instead of 78 any number up to 255 may be specified, but 78 corresponds to actual editor's window width in 80x25 screen display mode. turn display to monochrome; turn display to maximum allowable number of screen lines; open file(s) for reading only, exclude risk of change(s); force usage of short filenames; display on-line help.

EDIT.COM is able to accept from command line also the following options: /B /H /R /S /?

6.10

EXPAND.EXE unpacker for compressed files

EXPAND.EXE is unpacker for files compressed with Microsoft's COMPRESS.COM utility. Each such compressed file contains only one original file and inherits its name, except that the last character in suffix is replaced with underscore, for example *.TX_ instead of *.TXT. Releases of previous MS-DOS versions and several other software packets comprise such compressed files together with EXPAND.EXE unpacker utility. In particular, EXPAND.EXE is present in SFX archive DOS62SP.EXE, which can be downloaded from Microsoft's FTP-server ftp://ftp.microsoft.com/softlib/mslfiles/ .

168

Chapter 6: Selected utilities for MS-DOS7


Name of EXPAND.EXE unpacker utility must be followed in command line by name of that compressed file, which is to be unpacked, and then by a name, which should be appointed to the restored original file, for example: Expand.exe E:\DOS\MSDOS622\Country.tx_ C:\DOS\MS6\Country.txt Both paths in the shown example are optional. The path preceding a name for the restored file is interpreted as a prescription to write the result of unpacking into that directory. If paths are omitted, then compressed file will be searched for inside current directory only, and the result will be placed just there, but in this particular case it is permissible, because compressed file and original file have different names. Wildcards (2.01-03) in filenames are not allowed by EXPAND.EXE, but there may be several names of compressed files in one command line. In this case the last specified name must be a directory name (without final backslash), where unpacked files should be written. Name of the current directory with this mission can't be omitted, but may be represented with a dot (2.02-03). Source files, compressed with old versions of COMPRESS.COM, comprise no information about original names of compressed files. Such files will be unpacked properly, but their original names will not be restored, if explicit new name specification is not given in command line. Therefore sharing of a common directory as both source and target should be avoided because of possible name conflicts. Note 1: compressed files in Windows-2000/XP releases also are marked with underscore at the end of suffix, but these files are compressed by other algorithm. Their unpacking in MS-DOS7 can be performed by EXTRACT.EXE (6.11).

6.11

EXTRACT.EXE unpacker for *.CAB files

The EXTRACT.EXE utility unpacks files, compressed by MAKECAB.EXE packer. Microsoft uses this algorithm for compression of separate files in Windows-2000/XP releases, and also for compiling large multi-volume archives with *.CAB suffix in releases of Windows-95/98/ME. EXTRACT.EXE enables to extract separate files from large *.CAB archives and to display their contents. Here is an example of command line for extracting a list of contents from a multi-volume *.CAB archive: Extract.exe /A /D E:\Win95\OSR2.PE\Win95_21.cab > C:\Temp\List.txt where: E:\Win95\OSR2.PE\ example of a path to one *.CAB archive from Windows-95 release. Other volumes of the same archive are implied to exist in the same directory. If path is omitted, archive is searched for in current directory only.

169

Chapter 6: Selected utilities for MS-DOS7


/D /A an option, prescribing to display a table of contents without unpacking of archive's volume(s). an option, prescribing to apply the same operation to all following volumes of the same archive. In this particular case it induces processing of CAB-archive volumes from 22-nd to 26-th.

As far as *.CAB archives contain a large number of files, it's difficult to perceive their long tables of contents from a scrolling screen. This is why in the shown example output is redirected into file List.txt, which may be analyzed more conveniently with a viewer (6.19) or with an editor program (6.09). Here is one more example of EXTRACT.EXE usage for extracting of a single file from a multi-volume archive, when it is not known beforehand, which particular volume contains the required file: Extract.exe /A /Y /L C:\Windows\System Win95_02.cab Msvcrt40.dll where: an option, prescribing to overwrite any synonymous file in the target directory without prompt. /L an option, prescribing to interpret the following item (C:\Windows\System) as a target path for unpacking. When /L parameter is omitted, default target for unpacking is the current directory. Msvcrt40.dll a name example for the file to be unpacked (there may be several filenames specified for unpacking). In the shown example the first specified filename (Win95_02.cab) is interpreted as a name of that archive volume, where a search for the required file should start. All following filenames are interpreted as names of those files, which should be extracted and decompressed. Execution of the shown command line initiates a search procedure through volumes from 02 to 26 for the specified file. In fact it will be found in the 13-th volume and will be unpacked into C:\WINDOWS\SYSTEM directory, overwriting there a corrupted sample of the same file. Such procedures are much more fast, than total unpacking of a software release. EXTRACT.EXE doesn't allow wildcards (2.01-03) in filenames, but accepts one more optional parameter /E , which forces to unpack all contents of the specified CAB-file. In this case a particular name(s) for the files to be unpacked shouldn't be specified. The /E parameter is expedient for unpacking non-cabinet compressed files (those marked with underscore at the end of suffix) from Windows-2000/XP releases. But total unpacking of large *.CAB files in DOS takes too much time. A combination of /A and /E parameters deserves special caution, because it may initiate a process, which will take hours of time and a lot of disk's space. /Y

170

Chapter 6: Selected utilities for MS-DOS7


Note 1: some software vendors supply *.CAB archives, which are produced by other compression algorithm. Besides that, several mutually incompatible versions of EXTRACT.EXE are known. The most suitable unpacker for any given software release is that one, which is supplied within this release.

6.12

FC.EXE files comparison utility

The FC.EXE utility enables to compare two files, either binary or textual. Binary comparison is expedient for finding changed bytes in nearly identical binary files: FC.EXE displays byte number for each pair of mismatched bytes and these bytes themselves, taken from each of the compared files. Here is an example of command line for performing binary comparison: Fc.exe /B Trial2.com D:\Temp\Trial1.com where: /B an option, prescribing binary comparison. Trial2.com an example of the first file to compare; since its name isn't preceded by a path, it is implied to exist in the current directory. D:\Temp\Trial1.com a name example of the second file with preceding path. Binary comparison doesn't imply searching for match in mutually shifted successions of bytes. Textual comparison is based on line structure of textual files. FC.EXE compares textual files line-by-line and displays mismatched lines side-by-side. When order of correspondence between line successions becomes disrupted, FC.EXE can restore it by searching for a next group of matching lines. Both comparison and search conditions are specified by options in command line, for example: Fc.exe /A /C /L /LB9 /N /T /W /1 A:\Config.sys C:\Config.sys where: /A /C /L /LB9 /N /T /W /1 display 2 lines only (the first and the last) from each mismatched group of lines. disregard letter's case (for ASCII codes up to 127). prescription for ASCII textual comparison. limit example (9 consecutive mismatched lines) for a region of match search; default is 100 lines. prescription to display line numbers. prescription to avoid expansion of tabulation codes (09h) into spaces. prescription to ignore empty space (tabulation codes and spaces). a number example of consecutive lines that must match after a group of mismatched lines.

171

Chapter 6: Selected utilities for MS-DOS7


Note 1: binary comparison is the default for files having suffixes BIN, COM, EXE, LIB, OBJ, SYS. Other files are compared as textual by default. Note 2: in special applications one of the files to compare (or both) may be replaced by other sources (2.01-01), for example, by virtual device NUL or by CON device the console. The latter enables to perform comparison with keyboard input (1.04).

6.13

FDISK.EXE partitioning tool for HDDs

Disks, known by their letter-names, are logical disks. Contrary to those, physical hard disk storage devices have no letter-names. Writable storage space in physical storage devices may be divided into several partitions, and each partition may represent a separate logical disk. The FDISK.EXE utility is a proprietary MS-DOS7's tool for arranging partition structures in physical HDDs (Hard Disk Drives). Being launched without parameters, FDISK.EXE asks the user whether large disk support should be provided or not. Rejection of the offer means that arranged partitions within range 512 2048 Mb will be of FAT-16 type, otherwise FAT-32 type will be preferred. FAT system for partitions outside the mentioned range is assigned by default: FAT-32 for partitions larger than 2048 Mb, FAT-16 for partitions between 512 and 16 Mb, FAT-12 for 16 Mb and smaller volumes. Those apt to trust theirselves may specify command line parameters, enabling to get rid of undue questions and restrictions: Fdisk.exe /fprmt /actok The /fprmt parameter cancels query about large disks support and gives all rights on file system choice to the user. The /actok parameter enables to arrange an active partition in any physical hard disk drive (otherwise an active partition may be arranged in the first physical HDD only). Being launched in the shown way, FDISK.EXE presents a menu to select an operation: to display current partition structure, to delete or to create a partition or to make it active. The user is allowed to compose partition structure, but the latter is not written to disk at once. FDISK.EXE gives a chance to correct it. If a partition ought to be bootable, don't forget about making it active. Then you may exit FDISK.EXE. If partition structure has been changed, FDISK.EXE writes it to disk and exits into reboot, because created partitions must be registered by BIOS. PC's BIOS system appoints letter-names to registered partitions. Since that moment all registered partitions become "visible" in DOS as logical disks, but new logical disks are not yet formatted and therefore are inaccessible. New logical disks become accessible after formatting by FORMAT.COM utility (6.15). Besides interactive arrangement of partition structures, FDISK.EXE may be used as ordinary console utility with the following options:

172

Chapter 6: Selected utilities for MS-DOS7


Fdisk.exe /? Fdisk.exe /status Fdisk.exe /mbr display a short help. show available physical HDDs and logical disk's allocation. write or rewrite MBR (master boot record) on the first HDD, leaving its partition table intact (note 1). Confirming message is not displayed. acts just as /mbr, but enables to specify the addressed HDD by physical number: 1, 2, 3 and on are allowed, if these HDDs exist. Confirming message is not displayed.

Fdisk.exe /cmbr 2

Regardless to purpose of FDISK.EXE usage, its command line may be complemented with /X option, which forces to avoid extended support functions for access to disk(s). The /X option should be remembered, when ordinary usage attempts fail: the HDD either is not recognized, or is found inaccessible, or the PC gets hanged with "Stack overflow" message. Such outcomes may take place because of incorrect configuration, hardware faults, virus MBR infection. Not necessarily, but in some such cases the /X option may help. If an identical partition structure should be formed on several new HDDs, then automatic (non-interactive) arrangement of partitions should be preferred. Automatic writing of a partition structure onto a HDD can be initialized by the following example of command line: Fdisk.exe 1 /PRI:2000 /EXT:8000 /LOG:8000 /Q where: 1 addressed physical HDD number (1, 2, ...). /PRI:2000 arrange a primary partition, for example, 2000 Mb. If FAT-16 file system should be formed in this partition, then /PRIO: parameter (instead of /PRI:) should be specified. /EXT:8000 arrange extended partition, for example, 8000 Mb. /LOG:8000 arrange logical disk, for example, 8000 Mb, inside the extended partition. For sizes not larger than 2000 Mb parameter /LOGO: (instead of /LOG:) means that FAT-16 file system should be formed. /Q "quiet" option, i.e. run without screen messages. Having finished its job successfully, FDISK.EXE initializes reboot. Note 1: overwriting of MBR enables to get rid of MBR bugs, including those inflicted by viruses. However, some BIOS extensions and boot managers use non-standard types of MBR, which can't be restored by FDISK.EXE. In such circumstances other ways of MBR restoration should be preferred (example in 9.02-03). Note 2: Microsoft's FDISK.EXE doesn't support non-sequential placement of partitions and therefore gives no opportunity to bypass worn-out regions of physical disk's surface. FDISK.EXE can't arrange correctly those partitions, which cross the

173

Chapter 6: Selected utilities for MS-DOS7


8.4 Gb boundary in physical disk's space. FDISK.EXE often can't cope properly with partitions, arranged by other operating systems: either can't delete such partitions, or may arrange new partitions, overlapping the former ones. Note 3: most significant drawbacks of original Microsoft's FDISK.EXE have been corrected in its new unofficial version (dated 2006), which can be downloaded from site http://radified.com/Files/FDISK.EXE . Besides that, completely new synonymous utility has been compiled by Brian E. Reifsnyder. Version 1.30 (dated 2003) of this utility, packed into archive fdisk130.zip, can be downloaded from server ftp://ftp.uni-koeln.de/pc/msdos/diskutils/ Note 4: any change of existing partitions structure, performed by FDISK.EXE, causes total data loss within affected partition(s). Partition(s) rearrangement without data loss may be performed by more powerful tools, for example, by PowerQuest's Partition Magic utility (bought now by Symantec Co.). Note 5: FDISK.EXE can't arrange partitions in HDDs, accessed via a network or controlled by drivers. Because of the latter reason FDISK.EXE often can't cope with external storage devices having SCSI or USB interface. In such cases other utilities may suit, for example, BTFDISK.EXE (from Buslogic) or TFDISK.EXE (from TEKRAM). Archive DC390FBW.ZIP, comprising TFDISK.EXE, can be found in internet site http://www.neuron.alt.ru/drivers/Driver/Controllers/ , in its subdirectory TEKRAM. A SFX archive DOSASPI.EXE, comprising BTFDISK.EXE, is present in subdirectory BUSLOGIC of the same site.

6.14

FIND.EXE word(s) searching filter

The FIND.EXE utility acts as a filter for textual data: it receives lines of text from a file or via redirection, selects lines with or without a certain combination of characters, and sends selected lines into standard output channel (STDOUT) for being displayed on the screen by default. Here is an example of word(s) filter usage for searching lines with a specified string of characters: Find /N /I " INT 13 " C:\DOS\SRV\Drives.txt where: /N an option, prescribing to accompany the displayed lines with their line numbers. /I an option, prescribing to ignore the case of letters in specified string of characters. " INT 13 " an example of characters string to be searched for, enclosed in double quotes. Note spaces between words and each of adjacent double quotes this guarantees finding of whole words, but not parts of other words. C:\DOS\SRV\Drives.txt an example of a file to be analyzed (with preceding path). If path is not specified, the file is implied to exist in the current

174

Chapter 6: Selected utilities for MS-DOS7


directory. There may be several filenames specified in one line one-by-one or by means of wildcards (2.01-03). The shown example of command line will display on the screen all lines of the analyzed file, containing words INT 13, and a short message reminding which file has been analyzed. Lines will be shown preceded by their numbers: this will help you to find them later while editing the same file. If you expect that the displayed listing may happen to be too long, you may send output into a file (2.04-03) or to the viewer MORE.COM (6.19). Having finished the search, FIND.EXE returns errorlevel 0, if it has found the specified string of characters at least once, or errorlevel 1, if this string hasn't been found in the analyzed text. Errorlevel may be used to determine the outcome of search (see articles 3.15-03 and 6.03). The next less typical example shows FIND.EXE counting lines in a textual file: Find.exe /V /C "" < Draft.txt where: /V an option, prescribing to display all lines NOT containing the specified string. /C an option, prescribing to display only the count of lines meeting the specified condition. "" an empty specification of a string to be searched for. < Draft.txt an example of a file to be analyzed, sent via input redirection (2.04-02). Since the filename is not preceded by a path, this file is implied to exist in the current directory. Having got input via redirection, FIND.EXE doesn't add its reminding message to the displayed result.

Void string to be searched for is regarded by FIND.EXE as a special non-existing object. Therefore FIND.EXE will simply count all the lines, including the empty ones. After counting the lines FIND.EXE always returns errorlevel 0. The third usage example presents lines of a batch file. Suppose that the target path is given as a value of environmental variable %P%, and it is not known, whether it has a final backslash or not. Since DOS is not indifferent to absence of a the final backslash, you need to append it, if it isn't specified yet. This may be done in the following way: echo %P%\\ | Find.exe "\\\" > nul if errorlevel 1 set P=%P%\ In the first line FIND.EXE analyses redirected output of the ECHO command and tries to find specified combination of symbols, which will be present there if the given path contains final backslash. STDOUT output of FIND.EXE presents no interest and is sent to NUL (into nowhere). The result becomes known via the errorlevel value, left by FIND.EXE. It is analyzed in the second line of the presented example. Errorlevel 1 means

175

Chapter 6: Selected utilities for MS-DOS7


that FIND.EXE has found no final backslash in the given path, and then the SET command (3.26) will append the missing backslash. The last (fourth) usage example is also a part of a batch file. Suppose that you have activated a procedure, which prepares a list of files (%Temp%\Files.lst) to be packed into an archive, and want to prevent twice-fold packing, when this list contains nothing more except archives of the same kind (RAR, for example). This can be achieved by the following command lines: Find /C /I /V ".rar" < %Temp%\Files.lst | Find ": 0" > nul if not errorlevel 1 echo Chosen file(s) already RAR-archive(s) if not errorlevel 1 goto NO_PACK In the first line the leftmost call for FIND.EXE reads filenames from the list line-by-line via input redirection, and counts only those lines, which don't contain filenames with ".RAR" suffix. The count result is redirected via STDOUT to the second (rightmost) call for FIND.EXE, which is "waiting" for zero count. When the count result really is zero (i.e. there are no other files except RAR archives), the rightmost call for FIND.EXE leaves errorlevel 0. This errorlevel value is checked in second and third lines of the example. The second line displays an error message, and the third line performs a jump to label "NO_PACK", thus enabling to bypass packing operation.

6.15

FORMAT.COM formatting tool for disks

The FORMAT.COM utility arranges logical disks on storage media, including diskettes and partitions of hard disks. Formatting includes testing of each sector's readability, writing sector's headers, creation of boot sector, of file allocation table (FAT) and of root directory. Clusters found to have non-readable sectors are marked in FAT as "BAD" and thus get out of use. Disks of 16 Mb and smaller are formatted with file system FAT-12. Choice of file system (FAT-16 or FAT-32) for partitions of hard disks is made with respect to FAT type identifier (A.13-6), assigned to particular partition beforehand by FDISK.EXE (6.13). Cluster size is calculated automatically as allowable minimum for given disk's size and FAT type. Formatting of floppy disks (diskettes) implies low-level recalibration of tracks, so that actual capacity of a diskette may be altered. An example of command line for formatting a diskette may look like this: Format.com A: /V:Archives /Q /F:1.44 /B where: A: a required letter-name specification of the disk to be formatted. Valid letter-names are appointed to disks at boot time, when disks are registered by BIOS. Those letter-names, which are appointed or

176

Chapter 6: Selected utilities for MS-DOS7


changed later by software means, are regarded by FORMAT.COM as invalid. /V:Archives an example of optional specification for volume's label: any word(s) of up to 11 characters long altogether. If this option is omitted, FORMAT.COM offers to specify volume's label at the final stage of formatting procedure. The user may reject the offer and just press ENTER; then this logical disk is given the NO_NAME label. /Q "quick format" an option prescribing to skip most time consuming operations: sectors test and headers writing. Formatting with "Q" option is used to delete all contents of those disks, which have been formatted yet and have sector headers as well as sectors themselves in good condition. If there is a doubt about it, quick formatting can't be recommended. /F:1.44 optional size specification (for floppy disks only). Allowable sizes are: 160, 180, 320, 360, 720 (kb) and 1.2, 1.44, 2.88 (Mb). Instead of the /F option you may use other forms of size specification, which are shown in note 1 below. When neither of allowable size options is specified, FORMAT.COM is able to determine suitable size based on BIOS' CMOS settings and on drive's sensor signals. /B an option prescribing to reserve space for system files in order to make the disk bootable later. Instead of /B you may specify /S, which means the same plus copying of DOS's system files into the root directory of the formatted disk. System files (COMMAND.COM, IO.SYS) are implied to exist in the root directory of PC's main bootable disk. Contrary to other system files, MSDOS.SYS is not copied: FORMAT.COM creates an empty sample of this file anew. Modern hard disk drives have a fixed track structure. It can't be altered by formatting procedure. Therefore disk's size, number of sectors and other similar format parameters shouldn't be specified for formatting HDD's partitions, for example: Format.com D: /s /c /z:64 where: /c an option prescribing to test clusters that are currently marked "BAD". Sometimes this enables to revive disks and diskettes, which have got a marked "BAD" sector in their first track. But testing of numerous bad clusters may considerably increase the time spent for formatting. an option forcing to arrange 32-kb clusters, each containing 64 sectors. It may be needed, if you intend to expand this partition later. The /z:1 option enables to arrange FAT-16 file system on small disks (from 4 to 16 Mb). But most often the "/z:" specification is omitted, because the default cluster size is considered the best.

/z:64

177

Chapter 6: Selected utilities for MS-DOS7


Note 1: instead of total size of a floppy disk you may specify number of tracks and number of sectors in each track, for example: /T:80 /N:18. One more alternative is to use the following parameters (instead of the /F option): /1 format an obsolete one-sided diskette; /4 format a 360 kb floppy in 1.2 Mb 5.25-inch drive; /8 format 8 sectors per track. Note 2 original Microsoft's FORMAT.COM (dated 1998) can't cope properly with formatting partitions beyond 64 Gb. Corrected version of FORMAT.COM (dated 2006), packed into SFX archive FDSKFRMT.EXE, can be downloaded from http://www.mdgx.com/files/FDSKFRMT.EXE .

6.16

LABEL.EXE volume's label changing tool

Volume's label is a word or a group of words of up to 11 characters long, used as a storage media identifier. Volume's label is written into boot sector (A.03-4) and, besides that, into a hidden entry of the root directory. Most often volume's label is appointed during formatting procedure, but it may be assigned or changed later by the LABEL.EXE utility, for example: Label.exe R:RAMDRIVE where: R: a specification example for a disk which should have its volume label altered; when disk is not specified, the current disk is taken by default. RAMDRIVE an example of volume label to be assigned to specified disk. When volume label is omitted, LABEL.EXE shows current label of specified disk and offers to type a new one. New label specification may be accepted via redirection too (2.04-02, 2.04-05). If user rejects the offer, he is prompted to delete (or to preserve) the current label. Having finished its job, the LABEL.EXE utility leaves behind the following errorlevel values: 082 015 002 000 label writing attempt has failed. invalid letter-name, no corresponding drive. drive has no removable storage media inside. disk is either accessible or non-formatted. Anyway, writing of volume's label hasn't been attempted.

The returned errorlevel value may be determined just as it is shown in articles 3.15-03 and 6.03. As far as the returned errorlevel value is informative, the LABEL.EXE utility is sometimes used to test disk's accessibility (example - in article 9.03-02).

178

Chapter 6: Selected utilities for MS-DOS7 6.17 MEM.EXE memory allocation explorer

The MEM.EXE utility is called in order to display information about amount of available memory, about its allocation, about loaded resident modules, for example: Mem.exe /A /C /P where options are: /A append summary with data about free space in HMA area. /C show a summary table of memory usage. The first column of this table enlists names of resident modules, the rest columns details of memory allocation. Instead of the /C option there may be specified: /D show status of resident modules and drivers; /F show nothing but amount of free memory; /M:HIMEM show details about a particular resident module (HIMEM in this example). Its name, specified after the /M option, must be separated by a colon. Names of modules should be taken from the first column of summary table. /P make a pause after each screenful of information.

6.18

MODE.COM peripherals interface tuner

The MODE.COM utility implements a number of interface configuration functions for ports, for video card and for character generator. A summary table of current subordinate equipment settings is displayed by MODE.COM utility, when it is called with /STATUS option: Mode.com /STATUS 6.18-01 MODE.COM: ports tuning operations

Interface tuning operations for serial ports (COM1, COM2, COM3, COM4) are performed by MODE.COM as it is shown in the following example: Mode.com COM1:11,E,8,2,B where: 11 E 8 2 set the 110 baud rate; values 11, 15, 30, 60, 12, 24, 48, 96, 19 are allowed and correspond to baud-rates 110, 150, 300, 600, 1200, 2400, 4800, 9600 and 19200 accordingly. implement even parity check; instead you may specify: O implement odd parity check; N no parity check. set 8 information bits per codeword (8 or 7 allowed). set number of stop bits (1 or 2 allowed).

179

Chapter 6: Selected utilities for MS-DOS7


B means normal reaction on port's errors. Instead of B there may be specified: E return ERROR message if connected device is busy; N don't repeat appeals to port after an error; P appeal to port repeatedly until CTRL-BREAK keystroke; R force switching to a new job even if the connected device didn't finish its previous job.

Interface tuning operations for parallel ports (LPT1, LPT2, LPT3) imply that the connected device is a printer. This is why for parallel ports the MODE.COM utility accepts other parameters, for example: Mode.com LPT1:80,6,B where: 80 6 B number of characters per line (80 or 132 allowed); number of lines per inch (6 or 8 allowed), means normal reaction on printer errors. Instead of B there may be specified just those options as for serial ports in the previous example.

The MODE.COM utility can readdress messages from parallel port (LPT1 LPT3) to any serial port (COM1 - COM4), thus enabling to use a printer with serial interface: Mode LPT1:=COM2 In order to cancel readdressing the MODE.COM utility should be called once more without further specifications after the same parallel port's name: Mode.com LPT1: 6.18-02 MODE.COM: textual video modes switching

The MODE.COM utility allows two forms of commands for switching textual video modes (A.10-1). Here is an example of the first (most obsolete) form of command: Mode.com co80 where: co80 means color video mode with 80 characters per line. Instead of co80 there may be specified: bw40 monochrome video mode, 40 characters per line; bw80 monochrome video mode, 80 characters per line; co40 color video mode, 40 characters per line.

The second form of command for switching textual video modes looks like this: Mode.com 80,25

180

Chapter 6: Selected utilities for MS-DOS7


where: 80 25 number of characters in a line (40 or 80 allowed); number of lines per screen height (25, 43 or 50 allowed).

Note 1: switching of textual video modes is accompanied with loading fonts anew. If current font has been installed by some other program (except MODE.COM), then change of a video mode by MODE.COM may cause a return from national font to default american font codepage 437. 6.18-03 MODE.COM: codepage selection

Commands for codepage preparation and selection operations, performed by MODE.COM utility, usually are written into the AUTOEXEC.BAT file (9.01-02). All these operations need the DISPLAY.SYS driver (5.02-02) to be loaded yet. The first of these operations is preparation of several codepages for further activation: Mode.com CON CP PREP=((437,850,866) EGA3.CPI) where: CON is a specification of the device, addressed by this operation. Instead of CON (console, i.e. keyboard and display) ports LPT1, LPT2 and PRN (printer) may be specified. CP PREP abridged name of operation "Code Page PREPare". (437,850,866) numbers of codepages (A.02-2) to be prepared. Only these codepages will be available for switching by CHCP command (3.04). EGA3.CPI name example of a file, containing all those codepages, which should be prepared.

Then one of prepared codepages should be made active by means of selection operation: Mode.com CON CP SEL=866 where: CP SEL abridged name of operation "Code Page SELect". 866 number example of the codepage to be activated. The codepage, activated for the CON (console) device, defines visual presentation of letters and symbols on the screen. In order to determine which codepage is currently active for a particular output device, you should call for the MODE.COM utility with device specification (CON, PRN, LPT1 or LPT2), with CP (Code Page) operation name and with the /STATUS option: Mode.com CON CP /STATUS

181

Chapter 6: Selected utilities for MS-DOS7


Any loaded codepage may become corrupted because of malfunction or because of undue actions of other software. In such cases the MODE.COM utility enables to load the active codepage once more with command: Mode.com CON CP REF where: CP REF abridged name of operation "Code Page REFresh".

6.19

MORE.COM page-by-page viewer

When long messages are sent to display as a whole, text is scrolled over the screen too fast to be perceived. In order to make long messages readable, the MORE.COM viewer sends them to display in a page-by-page manner. Each time the screen is full with text, the MORE.COM viewer suspends output, giving an opportunity to read the text. Each user's keystroke initiates display of the next text page. The MORE.COM viewer intercepts the messages, sent into standard output channel (STDOUT), either by means of input redirection (2.04-02): More.com < D:\MyDocs\Part2.txt or by means of intermediate redirection (2.04-05): Type D:\MyDocs\Part2.txt | More.com where: D:\MyDocs\Part2.txt is a name example of a file to be displayed, preceded by full path. When the path is omitted, the file is implied to exist in the current directory. Type D:\MyDocs\Part2.txt is an example of a command (3.30), sending its output via STDOUT output channel. Any other command, sending its output to STDOUT, may be specified instead. Note 1: messages sent to display via BIOS' interrupts or via STDERR output channel can't be intercepted by MORE.COM. Note 2: when the MORE.COM viewer accepts a message by means of intermediate redirection (2.04-05), this message is written into a temporary file, and access to a writable media is necessary. If current disk is non-writable or write-protected, and if a path to a writable media is not defined in environmental variable %TEMP%, then the MORE.COM viewer can't perform this mission. Therefore interception by means of input redirection should be preferred.

182

Chapter 6: Selected utilities for MS-DOS7 6.20 MOVE.EXE copying and renaming utility

The MOVE.EXE utility is used to rename directories and to move files from one directory into another. When source and target directories belong to different logical disks, moving is equivalent to copying, followed by deleting the copied file in the source directory. But when both source and target directories belong to the same logical disk, moving can be performed much faster by rearranging directory entries: reference record to file's first cluster is moved from one directory table into another without touching the file itself. The MOVE.EXE utility is able to decide, which way of moving should be implemented in each particular case. Moving of file(s) may be accompanied by renaming. Renaming of a directory is also performed by correcting an entry in parent directory table. Here is an example of MOVE.EXE usage for moving files from one directory into another: Move.exe /Y D:\MyDocs\Part*.txt C:\Dos\Chap*.txt where: /Y an option prescribing to overwrite synonymous file(s) in the target directory without prompt. When this option is not present in command line, MOVE.EXE tries to find it in the value of COPYCMD environmental variable. If COPYCMD value contains this option, you may overcome its action by specifying an opposite /-Y option in command line. D:\MyDocs\Part*.txt specification example for source file(s) with preceding path. Path may be omitted, if the file(s) reside in current directory. There may be several source specifications in one command line. C:\Dos\Chap*.txt target specification example, including a mask for renaming the files to be moved. The last of all such specifications in command line is interpreted as target directory specification. If the last name in this specification is not a name of an existing object, then this new name is assigned to the moved file. But when the last name in target specification is a name of an existing directory, file(s) are moved into that directory without renaming. In order to rename a directory, the last name in source specification must be not a mask and not a filename, but a name of an existing directory. In this case the target specification must consist of a new name only without path, even if the directory to be renamed is not a subdirectory inside the current directory.

183

Chapter 6: Selected utilities for MS-DOS7 6.21 SCANDISK.EXE disk(s) repairing tool

SCANDISK.EXE is a program for examination and repairing diskettes and hard disk drives, formatted with FAT12, FAT16 or FAT32 file systems. SCANDISK.EXE checks boot sector, reveals lost clusters, corrects crosslinks in FAT table, examines writeability of disk's surface in each cluster. Non-readable clusters are marked in FAT as BAD and therefore get out of further use. The course of testing and location of bad clusters are displayed in a chart, shown below in fig.4.

Fig. 4
SCANDISK.EXE tries to rewrite information from bad clusters into good ones so as to restore integrity of each file. Being launched regularly, SCANDISK's maintenance procedures enable to keep your computer in good health for a long time. Details of test's structure are defined by parameters, stored in a separate file SCANDISK.INI, which must be present in the same directory with main SCANDISK.EXE file. SCANDISK.INI is a textual file. It contains comprehensive commentaries and can be edited by the user. If you have to check and repair a drive according to all parameters in SCANDISK.INI, you have to launch SCANDISK.EXE with /CUSTOM option in command line. When /CUSTOM option is not specified, only those parameters in [ENVIRONMENT] section of SCANDISK.INI file will be taken into account. Parameters in command line have priority over those specified in SCANDISK.INI file. SCANDISK.EXE is able to fix automatically most part of the errors it finds, but for that it has to be launched with parameters in command line, for example:

184

Chapter 6: Selected utilities for MS-DOS7


Scandisk.exe C: /AUTOFIX /NOSAVE /NOSUMMARY /SURFACE where: C: specification example of a disk to be examined. If you want all accessible disks to be processed, you should specify /ALL instead of particular letter-name. Compressed disks should be specified with their volume-name, for example: C:\DRVSPACE.000 /AUTOFIX fix errors without prompt. On the contrary, when automatic repairing isn't desirable, you may specify the /CHECKONLY option instead of /AUTOFIX. /NOSAVE delete lost clusters rather than save them as files. This option can be used only if the /AUTOFIX option is specified too. By default lost clusters are transformed into files *.CHK in the root directory of the same disk. /NOSUMMARY don't stop at summary screens. This option can be used together with either /CHECKONLY or /AUTOFIX options. /SURFACE perform a surface scan after other checks (surface scan shouldn't be applied to compressed disks).

When /AUTOFIX option is not specified, then before making any changes SCANDISK.EXE offers you to write disk's current state onto UNDO-diskettes. This gives an opportunity to restore current disk's state later, if fixes will happen to inflict something wrong. While making a decision about UNDO diskettes, it should be taken into account, that amount of data in current state record may be enormous. Large partitions of modern HDDs may require hundreds of UNDO-diskettes and a lot of time. This is why SCANDISK's offer about UNDO-diskettes most probably should be rejected. If nevertheless original disk's state was saved in UNDO-diskette(s), and restoration of this state has been found necessary, then restoration procedure must be performed at once, before any new files are written onto this disk: Scandisk.exe /UNDO B: where: /UNDO parameter initiating restoration procedure. B: specification example of a drive, which will be used to read the UNDO-diskette(s). One more operation, performed by SCANDISK.EXE, is exploration of whether a particular file is fragmented or not: Scandisk.exe /FRAGMENT C:\WINDOWS\SYSTEM\Kernel32.dll where: /FRAGMENT an option, inducing exploration of file's fragmentation.

185

Chapter 6: Selected utilities for MS-DOS7


C:\WINDOWS\SYSTEM\KERNEL32.DLL a specification example for a file to be explored. If path is omitted, this file will be searched for in current directory only. Regardless to performed operation, SCANDISK.EXE accepts from command line one more option the /MONO option, prescribing to configure its output for a monochrome display (by default the output messages are displayed in color). Note 1: SCANDISK's procedures can't be applied to network drives, to CD/DVD-ROMs, to RAM-disks and to virtual disks, created by utilities ASSIGN.COM, JOIN.EXE and SUBST.EXE. SCANDISK.EXE also can't cope with those damages of disk's data, which make this disk inaccessible. However, inaccessible disks with damaged boot sector sometimes may be restored with NDD.EXE or with DISKEDIT.EXE utilities from Symantec Co. Note 2: SCANDISK.EXE needs direct access to the processed disk and therefore can't be used inside a multi-tasking environment. A call for SCANDISK.EXE inside the DOS "window", arranged by WINDOWS OS, in fact invokes another program the SCANDSKW.EXE from the \WINDOWS directory. Note 3: SCANDISK.EXE with /AUTOFIX option shouldn't be applied to disks, suspected of being infected by virus. This may cause irreparable data loss. Such disks should be processed by an antivirus scanning program first (for example, by DRWEB.EXE). Note 4: by default SCANDISK.EXE regards as an error each long filename, appointed by WINDOWS OS. Attempts to fix all such errors may have awful consequences. SCANDISK.EXE wouldn't do harm to long names, if section [ENVIRONMENT] of SCANDISK.INI file contains lines: LfnCheck = Off SpaceCheck = Off Improved version of SCANDISK.EXE from WINDOWS-ME software release is more tolerant to long names and can be used under MS-DOS7. Note 5: data rewriting from bad clusters into good ones can't be performed, unless there are some free clusters on the same disk. Of course, you can remove any file in order to get some free space, but there are utilities (version 2.50 of PKZIP.EXE archiver, for example), which fill diskette(s) with a single file leaving no free space at all. Because of one corrupted sector such file can't be neither read nor repaired, since there are no spare sectors. Filling of the whole media with one file should be avoided.

6.22

SORT.EXE lines sorting filter

The SORT.EXE utility accepts textual lines from a file or via redirection and sends the same lines in another sorted order via STDOUT channel to the screen (the default), or to another file or device. Sorting is defined by the order of characters in ASCII code table.

186

Chapter 6: Selected utilities for MS-DOS7


The following example shows SORT.EXE usage for displaying a changed order of textual lines on the screen: Sort.exe /R /+12 D:\MyDocs\Unsort.txt where: /R an option, prescribing to reverse sorting order, i.e. from Z to A and then from 9 to 0. /+12 specification example for sorting lines according to characters in column 12. If this option is omitted, characters in column 1 will be taken by default. D:\MyDocs\Unsort.txt specification example for the file to be processed (with preceding path). File without preceding path will be searched for in current directory only.

Second usage example shows input from a source file via redirection and output redirected into another (target) file: Sort.exe /+9 < D:\MyDocs\Unsort.txt > D:\MyDocs\Sort.txt where: D:\MyDocs\Sort.txt specification example for the target file. If this file exists, it will be overwritten without prompt. Specification of the same file for both the source and the target is not allowed (data will be lost!). The last example shows input via intermediate redirection from another command and output of sorted lines to a printer: Type D:\MyDocs\Unsort.txt | Sort /+3 > PRN Note 1: redirection to a printer shouldn't be attempted unless you are sure that your printer is properly connected to LPT1 port, is switched on and is able to cooperate with MS-DOS. Note 2: both output redirection ( > ) and redirection via a "pipe" ( | ) need access to a writable media and can't be performed, if this condition is not met (2.04-03 2.04-05).

6.23

SUBST.EXE arrangement of virtual disks

The SUBST.EXE utility arranges virtual disks, used as an equivalent replacement for real paths. Originally SUBST.EXE has been developed as a means of access to subordinate directories for old programs (from DOS versions earlier than 3.0). Early DOS versions didn't "know" hierarchical directory structures, all files were stored in a single root directory. The SUBST.EXE utility enables to address a file in any subdirectory as though it were in the root directory of a disk. Nowadays the SUBST.EXE utility is used

187

Chapter 6: Selected utilities for MS-DOS7


rarely in order to squeeze more data into a limited length of command line and of environmental variable %PATH%. Here is an example of arranging a virtual disk with SUBST.EXE: Subst.exe V: D:\DATA386\For_K\MyDocs where: V: example of a letter-name for the virtual disk to be arranged. Letter-name must be free (not belonging to any real drive) and must be chosen within the limit, set by LASTDRIVE command (4.17, 4,18) in CONFIG.SYS file. D:\DATA386\For_K\MyDocs example of real disk and path to be assigned to virtual disk. If path is not specified, current disk and path are implied. In order to delete virtual disk, command line with a call for SUBST.EXE utility may look like this: Subst V: /D where: V: /D letter-name example for the virtual disk to be deleted. an option, prescribing to delete virtual disk.

Being executed without parameters, the SUBST.EXE utility displays a list of currently active virtual disks. Note 1: virtual disks, arranged by SUBST.EXE, can't be subjected to actions of the following utilities: Assign.com, Backup.exe, Chkdsk.exe, Defrag.exe, Diskcomp.com, Diskcopy.com, Fdisk.exe, Format.com, Label.exe, Mirror.exe, Recover.exe, Restore.exe, Scandisk.exe, Sys.com, Undelete.exe, Unformat.com. Note 2: the paths assigned to virtual disks remain accessible in an ordinary way. Note 3: virtual disks can be accepted by WINDOWS OS, but can't be arranged, when WINDOWS OS is loaded yet. If necessary, virtual disk(s) should be arranged before loading WINDOWS, preferably by SUBST.EXE utility launched from a line of AUTOEXEC.BAT file.

6.24

SYS.COM utility making disks bootable

At a certain stage of PC's booting process control is transferred to executable code, read from boot sector of the boot disk. In its turn, this executable code transfers control to a loader file, specified inside the same boot sector. In order to make a disk bootable with MS-DOS7, an appropriate executable code and the name IO.SYS of MS-DOS7 loader file must be written into disk's boot sector beforehand. Besides that, the IO.SYS loader itself together with command interpreter COMMAND.COM and MSDOS.SYS file (5.01-01)

188

Chapter 6: Selected utilities for MS-DOS7


must be present in the root directory of bootable disk. These boot ability conditions are prepared by SYS.COM utility. Command line for making a disk bootable may look like this: Sys.com C:\ A: where: C:\ example of a path to the source directory with those system files (IO.SYS and COMMAND.COM), which should be copied to new disk. If source path is omitted, system files will be searched for in the root directory of that disk, which has been used to boot the PC. letter-name example of that disk, which is to be made bootable. It must be recognized by PC's BIOS and must be formatted yet under the same version of DOS.

A:

Note 1: SYS.COM utility can't be applied to network disks, to CD/DVD-ROMs and to virtual disks, created by RAM-disk drivers or by utilities ASSIGN.COM, JOIN.EXE and SUBST.EXE. Note 2: the operations, performed by SYS.COM utility, are necessary, but are not sufficient for making bootable a HDD's partition. This partition must be marked active in disk's MBR by FDISK.EXE (6.13) or by some other similar program. Executable code of boot sector will be read for execution just from that single active partition. Note 3: contrary to IO.SYS and_COMMAND.COM system files, the MSDOS.SYS file (5.01-01) is not copied. SYS.COM creates it empty anew. Loading from a new disk with default settings is considered more safe, because former settings may be unsuitable in other circumstances. Note 4: in the 8-th version of MS-DOS the SYS.COM utility has been changed: it always uses the default path to the source directory, and can't accept this path from command line.

6.25
6.25-01

VC.COM file manager


Main properties of Volcov Commander shell

File manager Volcov Commander (VC), written by Vsevolod V. Volcov (Kiev, Ukraine), resembles the known Norton Commander file manager, but VC is more compact and more flexible for adaptation to user's demands. Though VC is an unfinished project and can't be considered quite good, nevertheless it is the best for making reparatory work comfortable under MS-DOS7. Version 4.99.07 of VC, packed into archive vc499.zip, can be downloaded from internet site http://www.fdd5-25.net/shells.php . Just this version, dated 1998, is described below. The latest alfa-version 4.99.08 of VC Shell is dated 2000.

189

Chapter 6: Selected utilities for MS-DOS7


This latest version, packed into archive vc49908a.zip, can be downloaded from site http://vvv.kiev.ua/download/ . VC.COM is not a file manager itself, it is just a start file. The whole VC release includes the main overlay VC.OVL, a number of code translation tables *.TBL, and the following configuration files: VC.INI VC.MNU VC.EXT VCARCH.EXT VCEDIT.EXT VCVIEW.EXT non-textual file with general configuration settings. configuration of a menu, invoked by F2 keystroke. suffix-defined services, invoked by ENTER keystroke. specifications of archive services. suffix-defined services, invoked by F4 (Edit) keystroke. suffix-defined services, invoked by F3 (View) keystroke.

All VC's configuration files, except VC.INI, are ordinary textual files, which can be edited with EDIT.COM (6.09) or with any other editor program for non-formatted textual files. Examples of several VC's configuration files are shown in articles 6.25-02 6.25-04. All files of the VC release must be stored in one directory, and the path to this directory should be assigned as a value to environmental variable VC. Therefore file AUTOEXEC.BAT should include a line, for example: set VC=C:\DOS\VC4 VC Shell may be launched from command line as an ordinary program, but it is usually launched automatically from the last line in AUTOEXEC.BAT file, for example: C:\DOS\VC4\Vc.com /TSR /no2E /noswap /nozoom where options are: /TSR activate TSR supervisor, which monitors all loaded later TSR modules and unloads them at VC Shell shutdown. This may help to release memory and sometimes enables to avoid necessity of PC's reboot. On the contrary, when TSR supervisor is not desirable, the /noTSR parameter should be specified instead. /no2E exclude execution of programs via undocumented INT 2E interrupt (8.02-89), use legal INT 21\AX=4B00h (8.02-53) for this purpose. INT 2E is shorter and faster, but is not reentrant and gives no access to local variables of the caller. If nevertheless INT 2E is preferred, you may specify /2E parameter instead. /noswap prescription to avoid swapping of VC's data from memory to a file on a HDD. VC's data swapping is based on CHS access, which is not compatible with large modern HDDs. On the contrary, in obsolete PCs data swapping may be desirable, and then you may specify the opposite /swap option. /nozoom don't zoom message windows (zooming is adopted as the default).

190

Chapter 6: Selected utilities for MS-DOS7


Other allowable options for VC.COM are: /BW set black and white palette for monochrome displays. An alternative to /BW is /LCD set special palette for LCD displays. Default is 16color palette, typical for textual video mode 03h (A.10-1). /std load VC into conventional memory. By default VC Shell prefers other choices, if there are any. When VC loads itself into conventional memory, you may specify also /big load the whole VC's resident module; /small load a part of module's code, requiring periodic replenishment from disk. /XMS prescription to load VC into XMS memory, if XMS memory manager HIMEM.SYS (5.04-01) is installed yet. Alternatives to /XMS option are: /noXMS avoid XMS memory usage; /EMS prefer EMS memory, if EMM386.EXE memory manager (5.04-02) is installed yet; /noEMS avoid EMS memory usage. /ini:Alter.ini use another configuration file with arbitrary name (Alter.ini in this example) instead of VC.INI. You may rename current VC.INI file, change VC configuration and press Shift-F9 "Save Setup": VC will be forced to create a new VC.INI file. Thus you may store a number of alternative settings in different *.INI files. /? display a short help.

Fig 5

191

Chapter 6: Selected utilities for MS-DOS7


Behind all parameters in command line VC.COM allows to specify a command, which should be executed just after launching the VC Shell itself. This opportunity may be expedient, for example, for refreshing a record of interrupt table contents, saved beforehand by ESCAPE.COM utility. When VC Shell is running, its appearance on the screen may be different, depending on initial settings, stored in VC.INI file. Usually directory's contents are displayed in one or two panels, as it is shown in fig.5. Main functions of VC Shell are accessible via "hot keys" and via mouse's buttons clicks as well. Those "hot keys", which are kept active by VC Shell, are enlisted below in decreasing importance order. Ctrl B toggles on/off the bottom keybar F9 activates the upper functional bar Ctrl F1 toggles on/off the left panel Ctrl F2 toggles on/off the right panel Tab toggles active left panel/active right panel Alt F1 enables to choose disk in the left panel Alt F2 enables to choose disk in the right panel Ctrl O toggles on/off both panels Ctrl Q toggles on/off Quick View window in non-active panel Ctrl L toggles disk info on/off in non-active panel Ctrl [ types the path from left panel into command line Ctrl ] types the path from right panel into command line Ctrl i types name of a selected file into command line Ctrl P toggles non-active panel on/off Ctrl U swaps panels Arrows shift menu item or selected file in active panel Home shifts selection to the start of current directory End shifts selection to the end of current directory F2 displays a user-defined menu (6.25-02) F3 invokes viewer to read a selected file F4 invokes text editor, if it is defined by the user F5 copies selected file or group into opposite panel Ctrl F5 as F5, but copies only one file, ignores group list F6 moves or renames selected file or prepared group Ctrl F6 as F6, but moves only one file, ignores group list F7 enables to create a directory F8 deletes a selected file or prepared file group Ctrl F8 as F8, but deletes only one file, ignores group list Ins adds highlighted item to a list for group operation Shift F9 writes current VC's settings into VC.INI file Ctrl A shows file attributes and enables to alter them

192

Chapter 6: Selected utilities for MS-DOS7


Ctrl C Ctrl E Ctrl F Ctrl N Ctrl R Ctrl F4 Ctrl F9 Ctrl \ Alt-letter Alt F6 Alt F8 Alt F10 Alt F11 Alt F12 F10 invokes directories comparison, marking endemic files moves last line from history table back into command line enables to define suffix(es) for selection with a mask toggles appearance of file's suffixes in panels causes re-reading of current directory contents enables to alter volume label for the active disk changes display video mode (Alt-F9 changes it too) causes a jump to the root of disk in the active panel search for a file in the current directory by name size of selected directory (in panel's "full" mode) displays previous command lines (the history) shows active panel tree, enables jump to any directory enables to make panels shorter with ARROW UP key enables to make panels longer with ARROW DOWN key exits current session and unloads Volcov Commander.

Functions of some "hot keys" are duplicated. Ctrl-J and Ctrl-Enter act just as Ctrl-i: write name of the selected file into command line. Ctrl-Z acts as ALT F10 shows active panel tree. "0" in the numerical keypad acts just as INS: adds the selected item to a list of items, being prepared for performing a group operation. Items, included in the list, are highlighted with colour. Several keys in the numerical keypad are charged with auxiliary functions for preparing group operations: Ctrl + includes all files of the current directory in group list + includes in group list the files, selected with a mask Ctrl discards current selection of files excludes files selected with a mask (wildcards allowed) Ctrl * inverts files selection in current directory * acts as "+", if list of files in current directory is not formed, or as "", if group list of files exists yet When a list of highlighted items is prepared, then operations F5 (copy), F6 (move), F8 (delete) involve all the items in the list. List of highlighted items exists as a temporary file VCLIST.000 in the directory, defined by environmental variable %Temp%. Inside VC configuration files (*.MNU, *.EXT) the prepared list of highlighted items is accessible via special macro commands !~@ (for the active panel) and %~@ (for the passive panel). Thus the user is given an opportunity to define its own group operations (examples in article 6.25-02). If both VC's panels are switched OFF, VC shell provides more opportunities to navigate along the command line with LEFT ARROW and RIGHT ARROW keys, to insert characters into command line, and enables to access its history list with UP and DOWN arrow keys. When NUMLOCK key is switched OFF, arrow keys in numerical keypad act in the same way.

193

Chapter 6: Selected utilities for MS-DOS7


Development of the described VC's version (4.99.07) has not been completed. Some functions, defined by the user via configuration files, may go wrong, when there are alien *.EXT or *.MNU files in the current folder, and also when an archive file is left opened in the non-active panel. Several "hot keys" are claimed active, but in fact are not or act in a wrong way: Alt F4 (edit) has no effect, use F4 instead Alt F5 (memory usage) has no effect Alt F7 (file's search) implemented since version 4.99.08 Ctrl M (restore group) has no effect Ctrl N (long file names) in rare cases may cause hanging Ctrl Z (show tree) may go non-stop until ESC keystroke F1 (VC's internal help) isn't available F6 (move and rename) being applied to a directory, disables mouse, compels to reload mouse driver. 6.25-02 Volcov Commander's menu file VC.MNU.

VC's wide capabilities of adaptation are achieved due to a variety of macrocomands, which are available inside its menu files (*.MNU) and inside its extension files (*.EXT). Certain groups of syntax symbols and digits, being encountered in VC's configuration files, are interpreted by VC Shell as a call for a macrocommand, and then are replaced by the result, returned by the same macrocommand. This result may be a name, a path, a line, etc. Here is a list of syntax symbol groups and corresponding macrocommands, provided by VC file manager version 4.99.07: ![prompt] invitation to input word(s) from keyboard. The other word(s), specified inside the square brackets, constitute a prompt, displayed before this invitation. Up to 10 independent similar invitations are allowed, implicitly enumerated from 0-th to 9-th. mark for a place to insert a copy of the word(s), which were typed in by the user in response to an invitation, enumerated by the specified number, from 0-th to 9-th. mark to insert letter-name of the disk, opened in active panel. mark to insert letter-name of the disk, opened in passive panel. mark to insert the path, opened in VC's active panel. Returned path ends with a backslash. mark to insert the path, opened in VC's passive panel. Returned path ends with a backslash. mark to insert short name (without suffix) of the file, selected with left mouse's button in VC's active panel. mark to insert short name (without suffix) of the file, selected with left mouse's button in VC's passive panel.

!0...!9 !: %: !~\ %~\ !~ %~

194

Chapter 6: Selected utilities for MS-DOS7


!~.! %~.% !~@ %~@ !! %% mark to insert short name (with suffix) of the file, selected with left mouse's button in VC's active panel. mark to insert short name (with suffix) of the file, selected with left mouse's button in VC's passive panel. mark to insert name of temporary file, containing a list of filenames, highlighted with right mouse's button in VC's active panel. mark to insert name of temporary file, containing a list of filenames, highlighted by right mouse's button in VC's passive panel. mark to be replaced with a single exclamation sign. mark to be replaced with a single percent sign.

Combinations of symbols, including the tilde sign ( ~ ), invoke those macrocommands, which truncate "long" filenames to 8 characters, and "long" suffixes to 3 characters. In all such combinations of symbols the tilde sign ( ~ ) can be omitted, and then the same macrocommands, being executed in "DOS window" of WINDOWS-95\98\ME OS, return long filenames "as they are", without truncation. The user is given an opportunity to specify groups of symbols, invoking any macrocommand, in any command line inside menu file (*.MNU) and inside extension files (*.EXT). All lines in these files can be typed with editor program for non-formatted textual files (6.09). Each item of menu is represented in VC.MNU file by a header line and by at least one command line. VC file manager considers command lines are those non-empty lines, which begin with at least one space (ASCII code 20h). On the contrary, the header lines must not begin with a space. In the header lines the first group of characters, followed by a colon, is interpreted as specification of the "hot key" to invoke function of this menu item. The rest group of words to the right of colon is interpreted as a name, representing this item of menu, when menu is displayed on the screen. When the user has chosen a menu item for execution, the VC file manager replaces all groups of symbols, used to call any macrocommand, by those data returned by corresponding macrocommand. This is done at once in all command lines, following the header line of the chosen menu item. Then these command lines are sent one-by-one for execution to COMMAND.COM interpreter, which is called anew for each command line. Because of this reason jumps between command lines are not allowed, and the values of environmental variables can't be transferred from one command line to the following command lines within the same menu item. Of course, all conditions for proper execution of batch files should be met (see introduction article to chapter 9). An example of VC.MNU file is shown below. Mentioned there files Edit.com (6.09), Fc.exe (6.12), Scandisk.exe (6.21) are programs taken from Windows-95/98 release. Files Arc.bat and Turn_off.com are those described in articles 9.03-01 and 9.05-02 of this book. All these files must be present inside directories, specified in the value of the %PATH%

195

Chapter 6: Selected utilities for MS-DOS7


environmental variable (2.02-02). As far as VC file manager has no internal help, file HELP.TXT, mentioned in the first item of the menu, is implied to contain a text written by you yourself. A path to HELP.TXT file is required to exist on one disk with COMMAND.COM interpreter. F1: Help @for %%Z in (%%comspec%%) do %%Z\ @Edit.com /R \DOS\VC4\Help.txt @!:\ F4: Search for a file or filemask in the current subtree @rem ![Type filename or mask to search for & press ENTER:] @echo. @if not !0"==" Dir !0 /P /A:-D /S /B F5: Compare a file with synonymous file in non-active panel @if !:!~\==%:%~\ echo Other panel must show other folder!! @if not !:!~\==%:%~\ Fc /L /N !~.! %:%~\!~.! > %%Temp%%\Y.t @if not !:!~\==%:%~\ Edit.com %%Temp%%\Y.t @if not !:!~\==%:%~\ del %%Temp%%\Y.t F6: Pack file(s) marked in the active panel into a ZIP-archive @Arc.bat ZIP !: !~\ !~ !~@ %: %~\ F7: Pack file(s) marked in the active panel into a RAR-archive @Arc.bat RAR !: !~\ !~ !~@ %: %~\ F8: Repair a disk with Scandisk @rem ![Type letter-name of the disk to repair & press Enter] @if not !0"==" Scandisk.exe !0: /custom F10: Switch the PC off cls @Turn_off.com Each group of command lines related to one menu item can be regarded almost as a batch file. The purpose of the first item is just display of a prepared text. But when DOS is transposed to a RAM-disk (9.04, 9.09), letter-name of this RAM-disk can't be known beforehand. Letter-name problem is solved otherwise: the first command line makes current the disk, specified in a reference to command interpreter. If DOS is transposed, the HELP.TXT file is copied to the same disk too. Therefore the path to HELP.TXT file in the second command line refers to the root directory of a current disk, whichever it is. After that the last command line of the first menu item restores former appointment of the current disk. The second menu item, called with "hot key" F4, presents a simple example of a query, performed by VC file manager, and also an example of conditional execution of a command, if user's response to the query isn't empty. Just the same can be said about the sixth menu item, called with "hot key" F8. Appeal to SCANDISK.EXE program via menu

196

Chapter 6: Selected utilities for MS-DOS7


is expedient because otherwise a very important /CUSTOM parameter (6.21) is often forgotten, and therefore testing procedures may go wrong. The third menu item, called with "hot key" F5, presents a useful procedure of finding differences between synonymous textual files, shown in the left panel and in the right panel simultaneously. The first command line checks, whether different directories are opened in VC's panels. If yes, the FC.EXE utility in the second command line compares selected files and sends a report into a