Special Edition Using Microsoft Windows XP Professional (3rd Edition)
If you still use DOS programs, you'll be glad to know that the DOS environment that Windows XP uses is highly configurable. I discussed the Virtual DOS Machine or VDM in the previous section. It provides a simulated MS-DOS computer environment in which your old DOS applications run. It's also run "underneath" the simulated Windows 3.x environment, so it's used by old 16-bit Windows applications as well. You can configure it in several ways:
You can choose from a great number of settings, including the following, all of which can be set for an individual program or as defaults to be used any time a command prompt window or DOS program is run. You can make the following settings:
In addition to these settings, you can set the search path and other environment variables, specify memory requirements (for EMS and XMS), and set other nitty-gritty options using Program Information Files (PIF files) and the System option in the Control Panel. Unless specified otherwise, Windows XP uses the file _DEFAULT.PIF, stored in the default Windows folder (usually either \WINDOWS or \WINNT), as the basis for MS-DOS sessions and running applications that don't have a PIF. When you alter the "properties" for DOS applications by right-clicking the application and making settings, you create a customized PIF file for that application. The result of running any DOS application, however, is that Windows XP Professional creates a PIF on-the-fly and assigns the default settings to it unless other settings are specified.
Customizing AUTOEXEC.NT and CONFIG.NT
You can choose to further configure the MS-DOS and Windows 3.x environment by modifying XP's equivalent of the old CONFIG.SYS and AUTOEXEC.BAT files. In Windows XP, as in Windows NT and Windows 2000, these files are called CONFIG.NT and AUTOEXEC.NT. They are the files used to configure each DOS VDM when it starts up. When you run a DOS or 16-bit Windows application, Windows XP Professional creates a DOS VDM by loading the DOS environment subsystem and sort of "booting up" DOS. In the process, it reads in settings from CONFIG.NT and AUTOEXEC.NT in just the same way the original DOS read CONFIG.SYS and AUTOEXEC.BAT when it booted. The difference is the filenames and the file locations. In this case, the files are in the SYSTEM32 directory (usually \WINDOWS\SYSTEM32 or \WINNT\SYSTEM32) instead of the root directory. Each time you run a DOS application in a new window (that is, each time a new VDM is created), Windows XP Professional reads the CONFIG.NT and AUTOEXEC.NT files. The great thing about this capability is that you can change the settings and rerun a program, and the new settings get read and go into effect immediately. It's like rebooting DOS after fine-tuning CONFIG.SYS and AUTOEXEC.BATexcept faster. Just remember:
The standard settings in CONFIG.NT set up when Windows XP is installed are shown in the following listing. The REM comments have been removed for brevity. (If you upgraded your computer from an earlier version of Windows, your CONFIG.NT may be different, as the installer may have retained some of your previous operating system's settings.) dos=high, umb device=%SystemRoot%\system32\himem.sys files=20
TIP On my computers, I always change the files setting to files=100, and add the line device=%SystemRoot%\system32\ansi.sys. For more information about ansi.sys, see the next section.
TIP If you need to specify different CONFIG.NT and AUTOEXEC.NT settings for various MS-DOS programs, see "Custom Startup Files" later in this chapter.
You can edit the CONFIG.NT and AUTOEXEC.NT files with a simple text editor like Notepad. Microsoft, for some reason, chose not to provide a comprehensive list of the settings permitted in CONFIG.NT in the online Help and Support, so I've listed them in Table 25.2.
If you enter CONFIG.NT into the Search box in Windows XP Professional's Help and Support Center, some of these terms are listed under the Full-Text Search Matches section of Search Results. Click on the individual terms for more information. The standard settings in AUTOEXEC.NT set up when Windows XP is installed are shown in the following listing. The REM comments have been removed for brevity. (And again, if you upgraded your computer from an earlier version of Windows, your AUTOEXEC.NT may be different). REM Install CD ROM extensions lh %SystemRoot%\system32\mscdexnt.EXE REM Install network redirector (load before dosx.EXE) lh %SystemRoot%\system32\redir REM Install DPMI support lh %SystemRoot%\system32\dosx REM The following line enables Sound Blaster 2.0 support on NTVDM. SET BLASTER=A220 I5 D1 P330 T3
Here's what these do:
TIP Editing these files properly is no piece of cake. You not only need to read about the configuration commands in Windows's Online Help and Support, I suggest you have at hand a good DOS reference like Que's Special Edition Using DOS 6.22, Third Edition.
Issues with DOSKEY and ANSI.SYS
Two of the most common enhancements used on MS-DOS computers were DOSKEY and ANSI.SYS. DOSKEY provided enhanced command-line editing: for example, the use of the up and down arrow keys to recall previous commands. ANSI.SYS gave DOS applications a way to easily control the position and color of text output onto the screen. Both enhancements are provided with Windows XP, although they don't work exactly as you might expect. ANSI.SYS can be made available for MS-DOS programs simply by adding the line device=ansi.sys to CONFIG.NT (or an alternate CONFIG file). Unfortunately, there is no ANSI cursor support provided for 32-bit Windows character mode (console) applications. Conversely, DOSKEYwhich has been enhanced significantly from the old DOS daysfunctions only in the 32-bit Windows console environment, and even if you attempt to load it in AUTOEXEC.NT, it does not function within the MS-DOS "COMMAND.COM" shell; that is, after you've run any MS-DOS program in the Command Prompt window. You can work around this limitation by instructing Windows to use CMD.EXE as the MS-DOS shell. Just add the line NTCMDPROMPT to your CONFIG.NT file. However, this may not work if you need to load Terminate-and-Stay-Resident (TSR) programs before your DOS application. Setting the Command Prompt Window Properties from a Window
The command prompt window displays a text-mode window that looks a lot like a DOS computer's screen. This window is actually a true 32-bit Windows application, although it can also execute old MS-DOS applications. Settings you make in to the command prompt window affect both the Window itself and any DOS programs run it. In fact, by far the simplest means for altering the DOS environment is via the Properties dialog box of a DOS window. If you need to fine-tune the DOS environment, this is most likely the way you will do it. When you open a command prompt window or run a DOS-based program, the window defaults to a standard size, background color, and font. Configuration options on the window's Control menu allow you to alter settings for the specific session. Options in the dialog bo XEs also let you save the settings to establish new defaults. You can set the properties like this:
If you're changing the properties for a specific window, the default is to change the properties for this window only. If you want to use these settings every time you launch this program, select Modify Shortcut That Started This Window, and then click OK. When you make this choice, Windows edits the PIF for the DOS application in question (or the _DEFAULT.PIF in the case of a CMD window), storing the settings. NOTE The Control menu's Edit command and its associated cascading menu options are covered in Chapter 5, "Using the Simple Supplied Applications," which describes the use of the Clipboard and OLE.
TIP Setting a large buffer size can be a real boon if you run batch files or other programs that normally cause text to scroll off the top of the screen. A large buffer enables you to scroll back the screen and check program flow and error messages.
Editing Advanced Settings for a DOS Application
If you're experiencing difficulties while running specific DOS programs, you should read this section to learn about making deeper changes to the properties settings for them. When you manipulate the properties (via the PIF) for a program, Windows XP Professional fine-tunes the VDM environment for the particular application, allowing it to run more smoothly, or in some cases simply allowing it to run at all. MS-DOS applications were designed to run in solitude. They assume that they are the only applications running and usually are memory hogs. Often they want at least 640KB of RAM and perhaps even extended (XMS) or expanded (EMS) memory. Running several non-Windows programs simultaneouslyespecially DOS programsis just asking for territorial conflict. To successfully accommodate the DOS-based applications still in use, Windows XP Professional must be ingenious in managing computer resources such as RAM, printers, modems, mouse devices, and display I/O. Significant sleight of hand is required to pull off this task smoothly, but Microsoft has done this fairly well, partly due to the use of PIFs. PIFs (program information files) are small files stored on disk, usually in the default Windows folder (\WINDOWS or \WINNT) or in the same folder as the application. They contain settings Windows XP Professional uses when it runs a related application. When you modify the properties of a DOS EXEcutable or shortcut, Windows XP, in turn, edits the associated PIF. With the correct settings, the program runs properly, sparing you the aggravation caused by program crashes, sluggish performance, memory shortages, and other annoying anomalies. PIFs have the same initial name as the application but use .PIF as the extension (123.PIF, for example). When you run an MS-DOS application (using any technique), Windows XP searches the application's directory and the system search path for a PIF with the same name as the application. If one is found, this file's settings are applied to the DOS environment by the DOS environment subsystem before running the application. If no PIF is found, Windows XP uses the default settings stored in a file named _DEFAULT.PIF, stored in the \WINDOWS or \WINNT folder. These settings work for most DOS applications, but not all; games and educational programs are likely to need the most modifications. TIP In earlier versions of Windows, you had to edit a PIF using the PIF Editor. You no longer need to do so. For all intents and purposes, you can forget about the existence of PIFs and focus on a DOS application's properties instead by right-clicking the application and choosing Properties. However, if you have specific instructions provided with an older application for making PIF file settings, follow the advice provided for the program in configuring the application's properties. DOS property settings can affect many aspects of an application's operation, such as (but not limited to) the following:
Some DOS programs come with PIFs, knowing you might run them under Windows. PIF settings from a Windows 3.x computer work under the Windows XP environment, so you can copy them to the appropriate directory, or take note of the settings on the Windows 3.x machine and reenter them on the Windows XP machine. Earlier versions of Windows (namely Windows 3.x) sported more settings for DOS programs, but because Windows XP Professional is more intelligent than its now-obsolete sibling, many of them are history. To edit these properties for a DOS program, do the following:
Poke through each tab, and use the ? (question mark) button for help on the settings. Educational and game programs will most often require you to adjust the Memory and Compatibility settings. NOTE If you are on a domain network or if you have disabled Simple File Sharing, and if the program is stored on an NTFS-formatted partition, the standard Security tab will also be listed in the property dialog. TIP The Screen tab's Usage options determine whether the application initially comes up windowed or full-screen. You still can toggle between views by pressing Alt+Enter. Of course, in full-screen display, the mouse is surrendered to the application. When you use a mouse with a windowed application, the mouse works within the window on its menus, and with Windows once you move the mouse back to the Windows desktop. No DOS-based mouse driver is needed; the Windows XP driver works in either case. If you use a shortcut to run an application that prints information to the screen, such as tracert, ping, or dir, see the next section to find out how to keep the window from disappearing before you can read the output.
Keeping a Command Prompt Window Open After Execution
When you run a command line program or batch file from the Command Prompt window, the window stays open after the program completes, and you can read any messages the program has printed. However, if you the program or batch file from a shortcut, or by entering its name into the Start, Run dialog, by default the command window will close automatically as soon as the program exits. To keep the window open, follow these steps:
TIP If the command prints more text than fits on the screen and some scrolls off, you can usually simply scroll the window up to see the first part of the output. If more text is generated than the scrolling function can keep track of, you can increase the amount of stored text by editing the shortcut's properties. Select the Layout tab, and increase the Screen Buffer Size Height value. Alternately, run the program from a batch file and send its output through the more command by adding | more to the end of the command line. This will display one screen at a time. Press Enter to see each successive page. Custom Startup Files
If you don't want every application's VDM to use the same AUTOEXEC.NT and CONFIG.NT settings, you can specify alternative AUTOEXEC and CONFIG files to be used instead, on an application-by-application basis. Here's how: From the application's Properties page, select the Program tab and click the Advanced button. You then see the dialog box shown in Figure 25.15; here, you can name alternative files to be used. Just enter the names of the files. You should create your own modified files for this use. Start by copying CONFIG.NT and AUTOEXEC.NT from the \WINDOWS\SYSTEM32 folder to a new folder (the folder of the DOS application in question is a good spot). Then, edit them with a plain text editor such as Notepad. Figure 25.15. You can specify a custom CONFIG.NT and AUTOEXEC.NT file for a given application.
|