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:

  • By configuring the user variables in the System dialog box, as discussed in the section "Setting Environment Variables."

  • By making selections from the DOS window's Control menu.

  • By making settings in the Properties sheet for a shortcut to the DOS application.

  • By setting up custom AUTOEXEC.NT and CONFIG.NT configuration files you can address most special memory or environment variable setting requirements a DOS program might have.

  • By entering environment-altering commands at the command prompt.

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:

  • Set the window font (including TrueType and bitmapped font styles)

  • Set the background and foreground colors for normal text

  • Set the background and foreground colors for pop-up bo XEs

  • Choose window or full-screen viewing

  • Set the default window position on the screen

  • Use or turn off the QuickEdit mode, which lets you copy text to the clipboard by highlighting it on the DOS window and pressing Enter

  • Use or hide the Windows XP mouse pointer in the application

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.

If your MS-DOS program gives error messages when it tries to open files, see "MS-DOS Program Can't Open Enough Files" in the "Troubleshooting" section at the end of this chapter.

If your older MS-DOS application displays lots of strange characters on the screen, especially the combination "[see "MS-DOS Application Displays Garbage Characters" in the "Troubleshooting" section at the end of this chapter.

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 files CONFIG.SYS and AUTOEXEC.BAT in your hard drive's root folder are ignored by Windows XP. They're there only to fool really old applications that won't run unless they see that these files exist.

  • The files CONFIG.NT and AUTOEXEC.NT in \WINDOWS\SYSTEM32 are used but only when Windows needs to start up an MS-DOS or Windows 3.x application. The settings in these files affect only the one DOS or Win3.x application you're running at the time, because they're read by the VDM program before it starts up the old application.

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.

Table 25.2. Commands Available for CONFIG.NT

Command

Description

country=

Sets the language conventions for the session.

device=

Installs loadable device drivers. Be careful with drivers that attempt to address hardware directly; they very likely won't work. However, you can load display drivers such as ANSI.SYS and memory managers such as EMM.SYS and HIMEM.SYS.

dos=

Tells Windows 2000 what to do with the Upper Memory Area (where to load DOS, as in dos=high).

dosonly

Allows only DOS programs to be loaded from a COMMAND.COM prompt. POSIX, OS/2, and Windows programs don't run. Note that a COMMAND.COM prompt and a Windows XP command prompt window's prompt are not the same. If you run COMMAND.COM, you get a DOS VDM window running the DOS command interpreter. Command Prompt windows run Windows XP's command interpreter (CMD.EXE), whose command set differs and expands on MS-DOS's.

echoconfig

Tells the VDM to print CONFIG and AUTOEXEC commands as they are executed from the files.

EMM

Configures the EMM (Expanded Memory Manager). Applies only when the program's properties specify that the value for EMS memory is greater than 0.

fcbs=

Sets the maximum number of file control blocks (FCBs). This setting is required only for truly ancient DOS programs.

files=

Sets the maximum number of open files. I recommend setting this to 100.

install=

Loads a memory-resident (TSR) program into memory before the window comes up or an application loads.

loadhigh=

Loads a device driver into the High Memory Area (HMA).

lh=

Same as loadhigh=.

ntcmdprompt

Replaces the COMMAND.COM interpreter with the Windows XP interpreter, CMD.EXE. After you load a TSR or when you shell out of an application to DOS, you get CMD.EXE instead, from which you have the added benefits of the Windows XP interpreter.

rem

Marks a line as a comment, causing the system to ignore it when "booting" the file.

stacks=

Indicates the amount of RAM set aside for stacking up hardware interrupts as they come in.

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:

  • Mscdexnt gives DOS programs access to CDROM and DVDROM data discs.

  • Redir gives DOS programs access to shared network resources.

  • Dosx provides expanded and extended memory services.

  • SET BLASTER tells DOS programs, through an environment variable, how to use the emulated Sound Blaster compatible sound services provided by the VDM.

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:

1.

Choose Start, Run.

2.

Enter cmd, and press Enter. This runs the Windows XP command prompt, a true 32-bit Windows program. The settings you'll make here are applied to the VDM as well.

3.

On the resulting command prompt window, click the upper-left corner to open the Control menu, and choose either Properties or Default.

  • Properties sets the properties for this box and optionally all other bo XEs with the same title (as seen in the box's title bar) in the future.

  • Default applies the settings to all DOS-based programs and command prompt windows from here on out (even with other programs running in them).

The resulting dialog box is the same in either case; only the window title is different. You can see it in Figure 25.13.

Figure 25.13. Here, you can set the default properties for all command prompt windows.

4.

Click through the four tabs, and notice the settings. You can click the ? (question mark) button in the dialog box and then click any of the settings to learn more about them. Some of the more useful settings are listed in Table 25.3.

Table 25.3. Some Useful Console Window Properties

Tab

Item

Description

Options

QuickEdit

Check to enable copying to the Windows clipboard by selecting text and pressing Enter. Uncheck if you need to use the mouse with an MS-DOS application.

 

Insert Mode

Check to set insert mode as the default for command line editing; uncheck to overwrite by default. (Press the Ins key while editing to toggle.)

 

AutoComplete

Check to have the Tab key automatically complete a partial filename you've typed on the command line.

Font

Size, Font

Sets the character size in the window.

Layout

Screen Buffer Size

Sets the width and number of lines of text that are stored for the screen; if larger than the window size, you can scroll back to view previously displayed text.

5.

Make changes as necessary, and click OK.

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:

  • The drive and folder (directory) that is selected as the default when an application starts

  • Full-screen or windowed operation upon launch

  • Conventional memory usage

  • Expanded or extended memory usage

  • The application's multitasking priority level

  • The application's shortcut keys

  • Foreground and background processing

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:

1.

Find the program file or a shortcut to it.

2.

Right-click and choose Properties. You then see a dialog box like the one shown in Figure 25.14. (In this example, I adjusted the properties for a DOS shareware game.)

Figure 25.14. Setting the property settings for a DOS application.

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:

1.

Create a shortcut to the DOS program or batch file.

2.

Right-click the shortcut, and choose Properties.

3.

Select the Program tab.

4.

Uncheck Close on Exit. The window will now stay open after the program exits. You'll have to close it manually when you're finished reading its output.

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.

Категории