Configuring the Command-Line Environment


In this section, I'll tell you a bit about how cmd may be adjusted to better meet your own needs. Some of these settings change how the Command Prompt window appears, whereas others change the software environment itself. If you were used to the MS-DOS environment, some of the software settings will be familiar, although the method of changing them is quite different.

Console Window Properties

You can make several changes to the appearance of console program windows . For better visibility, or to make a program look more like it's running under MS-DOS, you can press Alt+Enter to run the program in full-screen mode. If you run a DOS graphics program, this will happen automatically. In this mode, the program takes over the whole screen and all other Windows features disappear. You can always press Alt+Enter to bring back the Windows desktop.

You can set the screen mode and the number of lines that the window can scroll using the window's Properties dialog box, as shown earlier in Figure 9.5. You can also set the window's colors and font. Usually, you won't need to adjust the font. It's best to simply resize the window in the normal way and Windows will size the characters accordingly .

Changing the Search Path

By default, Windows sets the PATH environment variable to a standard list of Windows folders. If you plan on writing your own programs, batch files, Windows Script Host scripts, or other application programs, it's a good idea to place them in a folder of their own and then add that folder to the path.

You can change the search path in any of three ways.

First, you can set a new value for the PATH environment variable using the set command, as in this example:

 set path=c:\bat;%path% 

This makes the folder c:\bat the first folder in the path. The ;%path% ensures that the prior PATH folders are retained in the path list, otherwise you wouldn't be able to run programs not in c:\bat .

Second, you can use the path command, which is a "shortcut" version of set path :

 path c:\bat;%path% 

These commands have the same effect: They set the environment variable PATH to c:\bat , followed by the previous PATH definition.

Note

If the folder you're adding to the path has spaces in its name, put quotes around the name .


You could also add a new folder to the end of the search path with a statement like this:

 set path=%path%;"c:\bat" 

The ordering only matters if there are versions of the same command in more than one folder in the path; the version in the first folder to be searched will be the one that Windows runs.

Tip

If you mess up the path and cmd stops working, just close the Command Prompt window and open another. You'll be back in action.


Putting your own folders ahead of the Windows folders in the list can be a blessing or a curse. If you create a program or batch file with the same name as a standard Windows program, yours will run instead of the standard program. If this is what you want, great, but if not...the result can be very confusing.

The path and set commands only change environment variables for the current instance of the cmd program. If you close the Command Prompt window and open a new one, you'll be back to the initial default PATH .

The third way of changing the PATH makes the change appear in all future cmd prompt windows. To do this, you'll need to make the change on the System Properties dialog box, as I'll discuss shortly under "Setting Default Environment Variables."

Predefined and Virtual Environment Variables

Environment variables can be set in any of six places. If a given variable name is set in more than one place, the last definition encountered is used. The sources are processed in the following order:

1.
Predefined, built-in system variables (for example, APPDATA ).

2.
Systemwide variables defined in the System Properties dialog box.

3.
User -specific variables defined in the System Properties dialog box. However, a user-specific PATH definition does not replace the systemwide definition. Instead, it's added to the beginning of the system-wide definition.

4.
Variables defined in logon scripts (batch or WSH-type).

These first four sources are processed when a user logs on, and they form the user's default environment; the remaining sources are processed each time a new CMD process is started, and any changes are lost when cmd is closed.

5.
Variables defined in AUTOEXEC.NT , when and only when a DOS program is run.

6.
Variables defined on the command line, in batch files, or in Windows Script Host scripts through WshShell.Environment("Process") .

The following variables are defined by default for all users (systemwide):

Variable Name

Usual Value

ALLUSERSPROFILE

C:\Documents and Settings\All Users

APPDATA

C:\Documents and Settings\ username \Application Data

CommonProgramFiles

C:\Program Files\Common Files

COMPUTERNAME

computername

ComSpec

C:\WINDOWS\system32\cmd.exe

HOMEDRIVE

C:

HOMEPATH

\Documents and Settings\ username

LOGONSERVER

(Varies)

NUMBER_OF_PROCESSORS

(Varies)

OS

Windows_NT

Path

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem (this entry varies depending on the location of Windows)

PATHEXT

.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS

PROCESSOR_ARCHITECTURE

(Varies)

PROCESSOR_IDENTIFIER

(Varies)

PROCESSOR_LEVEL

(Varies)

PROCESSOR_REVISION

(Varies)

ProgramFiles

C:\Program Files

PROMPT

$P$G

SESSIONNAME

(Varies)

SystemDrive

C:

SystemRoot

C:\WINDOWS

TEMP

C:\DOCUME~1\ username \LOCALS~1\Temp

TMP

C:\DOCUME~1\username\LOCALS~1\Temp

USERDOMAIN

computername or domainname

USERNAME

username

USERPROFILE

C:\Documents and Settings\ username

windir

C:\WINDOWS


In addition, when command extensions are enabled, several "virtual" environment variables are available. The following environment variable names are computed dynamically if used on a command line or in a batch file:

Name

Value

CD

The current directory drive and path

DATE

The current date, formatted as by the DATE command

TIME

The current time, formatted as by the TIME command

RANDOM

A random number between 0 and 32,767

ERRORLEVEL

The exit status of the previous program

CMDEXTVERSION

The version number of command extensions

CMDCMDLINE

The command line used to start cmd itself


These entries don't really exist in the environment; cmd just fakes it by substituting the appropriate value when it runs into, for example, %date% . If you define an environment variable with one of these names, your fixed defined value will always supercede the dynamic value.

The maximum size for an individual environment variable (name, equals sign, and value) is 8,192 bytes. The total size of all environment variables must be less than 65,536KB.

Setting Default Environment Variables

To define environment variables permanently so that they are defined whenever you log on, click Start, right-click My Computer, and select Properties. Next , view the Advanced tab and click Environment Variables. Windows will display the dialog box shown in Figure 9.6.

Figure 9.6. The Environment Variables dialog box lets you edit default environment variables for your account or for all users.


The top part of the dialog box lets you define the default variables for your account. You can click New to add a new variable, or you can click Edit or Delete to modify an existing entry.

The lower part of the dialog box edits the default variables provided to all user accounts. These settings can only be edited by an Administrator account, and the settings may be overridden by user-specific entries.

An interesting feature of this dialog is that in most cases, if a variable is defined in the User Variables list, the user version overrides the System version. However, in the case of the PATH variable, the User version is prepended to the System version. This helps prevent users from accidentally ending up with a PATH that is missing all of the standard Windows program folders. Here's an example. If the System PATH is defined as

 C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM 

and the User PATH is defined as

 c:\bat;"c:\program files\my special stuff" 

then the user's actual PATH environment variable will be set to

[View full width]
 
[View full width]
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;c:\bat; "c:\program files\my special stuff"

at logon.

Note

If you're familiar with Windows Script Host, you can also modify the default environment variables with WSH scripts by modifying the WshShell.Environment("system") and WshShell.Environment("user") collections.


I recommend that you create a folder to contain your own personal batch files and scripts, perhaps named c:\bat , and add it to your user PATH as discussed here. This way, your scripts and batch files can be run from any command prompt you own, without worrying about where they're stored.

The Adjustable Prompt

I mentioned earlier that the command prompt shows you the shell's current directory. For example, the prompt

 C:\Documents and Settings\brian> 

shows that my current drive is C: and the current directory is C:\Documents and Settings\brian . If you manage computers or use networking software to work with several computers at once, you may find yourself confused at times, wondering to which computer a Command Prompt window belongs! You can modify the command prompt to display more (or less) information using the hieroglyphics listed in Table 9.9. cmd examines the PROMPT environment variable for any of the character codes listed in the table and replaces them with the appropriate information.

Table 9.9. Prompt Codes

Code

Prints

Example

$$

Dollar sign

$

$

(Dollar sign followed by a space)

A new line

$a

Ampersand

&

$b

Pipe character

$c

Left parenthesis

(

$d

The current date

Wed 04/24/2002

$e

ANSI escape (code 27) [*]

 

$f

Right parenthesis

)

$g

Greater-than sign

>

$h

A backspace

 

$l

Less-than sign

<

$n

The current drive

C:

$p

The current drive and path

C:\windows

$q

Equal sign

=

$s

Space

 

$t

The current time

19:13:37.21

$v

The Windows version number

Microsoft Windows XP [Version 5.1.2600]

$+

Zero or more + signs to show depth of pushd commands.

+++

$m

The UNC name of the network drive plus a space, if the current drive is not local; otherwise, nothing.

\\sumatra\cdrive

Any other

Any other character is printed literally.

 

[*] This was used in earlier Windows versions to construct ANSI screen control escape codes such as color changes, which would be interpreted by the ANSI.SYS screen driver. This is not helpful in the cmd.exe shell because ANSI.SYS is an MS-DOS driver and does not work in 32-bit console mode.

To set the prompt, construct the desired series of codes and issue the command

 set prompt=  codes  

or use the shortcut

 prompt  codes  

For example,

 prompt $t$h$h$h$h$h$h $m$p$g 

prints the time, backspaces over the number of seconds, adds a space, and then prints the network path and current drive and directory. The resulting command prompt looks like this:

 19:19 \sumatra\cdrive K:\> 

If you mess things up, prompt $p$g restores the prompt to its default value.

Tip

To make a permanent change to your prompt, right-click My Computer, choose Properties, Advanced, Environment Variables and then add a PROMPT definition under User Variables for....


AutoRun

Normally, when it first starts, cmd examines the Registry for a value named AutoRun under the keys

 HKLM\Software\Microsoft\Command Processor 

and

 HKCU\Software\Microsoft\Command Processor 

( HKLM and HKCU are short for HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER , respectively.) AutoRun values with type REG_SZ (string) or REG_EXPAND_SZ (string with environment variables to be expanded) are taken as commands to be run when an instance of cmd first starts up; first the HKEY_LOCAL_MACHINE value is examined, and if defined, run, and then the HKEY_CURRENT_USER value is checked.

AutoRun settings can be used to perform some of the functions that used to be provided by the AUTOEXEC.BAT file in DOS. In particular, you can use it to run DOSKEY to set macros via an AutoRun command (we'll discuss this later in the chapter).

If you want to run more than one command with the AutoRun feature, create a batch file, and have the AutoRun value specify this batch file's name.

If necessary, you can disable AutoRun commands by starting cmd with /D on its command line, as I'll discuss later in this appendix.

Note

This "autorun" setting is not related to the Autorun feature that launches applications or plays media when you insert a CD or DVD.


Configuring the MS-DOS Command Environment

As mentioned earlier, Windows XP uses a command prompt shell program named cmd.exe . As it turns out, to maintain maximum compatibility with old MS-DOS programs and old batch files, the original MS-DOS command.com shell is actually still available. The clunky old batch file language we all knewand loved?is still there.

Here's how it works: If you run an MS-DOS program in a Command Prompt window, cmd assumes that you're going to work in the 16-bit world for a while. So, when the DOS program finishes, the window switches to the command.com shell. You'll notice several differences:

  • The current directory name is changed to its old-style 8.3 equivalent. For example, if your current directory had been C:\Documents and Settings\naleks , when the DOS program exits, the directory will be displayed as C:\DOCUME~1\NALEKS .

  • Environment variable names change to all uppercase letters .

  • The extended versions of the built-in commands will be unavailable.

  • If you've run command.com explicitly, you cannot close the window by clicking its Close button command.com doesn't get the message to quit. You'll have to type exit to close the window.

These changes make it more likely that old programs and batch files will be able to run. However, if you want, you can keep cmd.exe as your command shell even when using MS-DOS programs, by configuring the MS-DOS environment.

To maintain compatibility with as many old DOS programs as possible, ntvdm can be configured to mimic an older environment. You can configure ntvdm's memory and window options through a properties dialog box, and you can configure the virtual DOS environment itself through configuration files that mimic the old CONFIG.SYS and AUTOEXEC.BAT files. Here is how the default configuration works:

  • By default, ntvdm gives an MS-DOS program as much regular and DOS Protected Mode Interface (DPMI) memory as it asks for. No Extended (XMS) or Expanded (EMS) memory is available.

  • Ntvdm reads configuration options from \windows\system32\config.nt and executes the batch file \windows\system32\autoexec.nt before running the program. These files are installed along with Windows and contain important default settings that permit the use of high memory, networking, and emulated Sound Blaster sound hardware.

These settings should work for most MS-DOS programs. You can modify these files to make changes that will apply to all MS-DOS programs, or you can create customized versions for specific applications; we'll discuss this in the next section.

If you need specially tuned DOS environments for special applications, you may want to configure Windows shortcuts for these applications, or at least create shortcuts that open custom-configured Command Prompt windows. To create a customized MS-DOS environment, right-click the name of the MS-DOS program you want to run and select Properties. If you change any of the default properties and save the settings, Windows will create a file with the same name as the program file, but with extension .PIF . This .PIF file holds the customized settings. It is listed in Explorer as a "Shortcut to MS-DOS Program." Use this shortcut to run the program. If you need to run a batch file before running the program, follow this same procedure, but create a shortcut to the batch files instead of the program itself.

Note

You must use the shortcut to start the MS-DOS program in order to take advantage of any configuration changes you've made. If you run the .EXE file directly, Windows will not know to look at the .PIF (shortcut) file.


Window and Memory Options

The Properties dialog box for an MS-DOS application shortcut ( .PIF file) lets you set the virtual MS-DOS environment's memory display and mouse properties. To customize these properties, right-click the MS-DOS application file itself, or if you've already created customized properties, you can right-click the MS-DOS Application Shortcut icon, and then select Properties.

Here are the most common settings to change:

  • The working folder on the Program page

  • The Extended Memory and Initial Environment options on the Memory page

  • The Always Suspend option on the Misc page

In the next sections, I'll describe all the property pages in more detail so you can see what configuration options are available. The General, Security, Summary, and Backup pages (if they appear on your system) are the same as for any other Windows file, so I won't describe them here.

Program Settings

The Program tab displays a typical Shortcut property page and has the following settings (see Figure 9.7):

  • Cmd Line The path to the MS-DOS program file or batch file, and any additional command-line arguments you need. If you enter ? on the command line, Windows will prompt you for command-line arguments when you run the shortcut. Whatever you type will be used in place of ? .

  • Working The drive and folder to use as the initial working directory for the program. If you leave this field blank, the initial directory will be the one containing the MS-DOS program. If the shortcut will be used by several people, you may want to use environment variables in this path. For example, "%userprofile%\My Documents" will specify the user's own My Documents folder.

  • Batch File Ostensibly, the name of a batch file to run before starting the program. As far as I can tell, however, this feature does not work.

  • Shortcut Key Optional. Specifies a hotkey that is supposed to start the program. However, this feature does not appear to work either.

  • Run Selects the initial window size: Normal, Maximized, or Minimized (icon). Full Screen is different; see the screen settings.

  • Close on Exit If this option is checked, the window will close when the program exits. If this option is unchecked, the window will remain open but inactive, and the title will include the word "Inactive." You will want to leave this checked in most cases.

Figure 9.7. The MS-DOS Shortcut Program tab. The Advanced button lets you specify a custom config.nt or autoexec.nt file.


Tip

If a DOS program fails to run, uncheck this box and try to run the program again. You'll then have time to read any error messages that appear.


The Program tab also lets you specify alternate configuration and startup batch files to use instead of CONFIG.NT and AUTOEXEC.NT . To change the configuration files associated with a shortcut, click the Advanced button and enter the paths and names of the desired files. The default values are %SystemRoot%\SYSTEM32\CONFIG.NT and %SystemRoot%\SYSTEM32\AUTOEXEC.NT . I will describe the settings in these files shortly.

Tip

If your MS-DOS program has timing or speed problems, it may be that it expects to be able to change the settings of the PC's timer chips. If you click the Advanced button and check the Compatible Timer Hardware Emulation option, the problem may go away.


Font Settings

The Font tab lets you select the font used when the program is running in a window. The default setting, Auto, lets Windows resize the font as you resize the window, but you can specify a fixed size. If you do, the window will not be resizable.

Tip

If you want to switch to a fixed font size, you can do it while the program is running. Right-click the upper-left corner of the program's window, select Properties, and view the Font tab. Make any desired changes and then choose Save Properties for Future Windows with the Same Title when Windows offers you this option.


Memory Settings

The Memory tab, shown in Figure 9.8, lets you specify the type and amount of memory to make available to the MS-DOS program. The plethora of memory types came about as different ways of coping with the original PC's limited memory hardware options. Some programs can use any type of memory, but others specifically require access to XMS or EMS memoryyour program's installation instructions will tell you what type of memory it requires or can take advantage of. Here's a list of the settings:

  • Conventional Memory, Total The amount of memory between 0 and 640KB. The Auto setting provides up to 640KB. You will probably never need to alter this setting.

  • Initial Environment The number of bytes to set aside for environment variables. Auto directs ntvdm to use the amount specified in the SHELL setting in CONFIG.NT . If you use complex batch files, you may want to increase this setting to 2000 bytes or more.

  • Protected If checked, this option prevents the program from altering memory in the range occupied by the simulated MS-DOS system components . Check this box only if you experience unexplained crashes.

  • Expanded (EMS) Memory If your program requires EMS (paged) memory, set this to Auto or a fixed number. (Your program's installation instructions will tell you if it needs EMS memory.)

  • Extended (XMS) Memory If your program can use XMS expanded memory, set this to Auto or a fixed number.

  • Uses HMA This option normally has no effect because the High Memory Area is used by the simulated MS-DOS program.

  • MS-DOS Protected-Mode (DPMI) Memory By default, this option is set to Auto. You can disable or permit a fixed amount of DPMI memory, if necessary.

Figure 9.8. The Memory tab lets you make various memory formats available to the DOS program.


Screen Settings

The screen settings let you determine whether the program has "direct" access to the whole screen at startup. These settings include the following:

  • Usage Lets you select between full-screen and window as the initial display mode. In full-screen mode, the MS-DOS program takes over the primary display and can display graphics.

  • Restore Settings at Startup If this option is checked, the last-used window size and font will be reused the next time you start the program. If you want to provide a consistent environment for multiple users, uncheck this box, make the appropriate initial settings, and then make the PIF file nonwritable by other users using file security settings.

  • Fast ROM Emulation When this option is checked, the Virtual DOS Machine emulates the graphics functions normally provided by the display adapter's built-in (read-only memory) BIOS program.

  • Dynamic Memory Allocation When this option is checked, Windows releases memory assigned to the virtual graphics display when the program switches from graphics to text display. If you get a blank screen when the program switches back, try unchecking this box.

When the MS-DOS program is running and attempts to change the display from text-based to graphical, Windows will automatically switch to full-screen mode. You can manually switch back and forth between full-screen and window mode by pressing Alt+Enter. If the program is using a text display, you can continue using it in window mode. If it is displaying graphics, however, the program will be suspended (frozen) and minimized unless it's in full-screen mode. Windows, unfortunately , can't display a little windowed version of the DOS graphical display.

Miscellaneous Settings

The Miscellaneous Settings tab determines how the program behaves when it's running in a window. Most of the settings are self-explanatory. The tab is shown in Figure 9.9. Here are the less obvious settings:

  • Always Suspend If this option is checked, the MS-DOS program will be frozen when it's not the active window. Because MS-DOS programs didn't anticipate multitasking, they tend to burn lots of CPU time even when idle. Suspending the program when you're not using it makes your system more responsive . However, if you are running a communications or database program that needs to run while you do other things, uncheck this box.

  • Idle Sensitivity This is also related to the idle CPU issue. Windows tries to guess when the DOS program is just spinning its gears doing nothing and gives it a lower priority when it thinks this is the case. A high Idle Sensitivity setting means that Windows will lean toward thinking the program is idle, resulting in snappier performance for other applications. A lower Idle Sensitivity setting will make Windows give the DOS application more time. The DOS application will be better able to perform background ( noninteractive ) processing, while making your Windows applications more sluggish . Raise this setting if your DOS program makes everything else too slow, or lower it if your DOS program can't get its job done. In the latter case, also uncheck Always Suspend.

  • Exclusive Mode Dedicates the mouse to the DOS program.

  • Fast Pasting Determines how quickly Windows will stuff simulated keystrokes into the MS-DOS programs when you paste in text from the Windows clipboard using Alt+space, Edit, Paste. If characters are lost when pasting, uncheck this option.

  • Windows Short Keys These check boxes let you determine which special keystrokes should be passed to Windows rather than to the MS-DOS programs. If your MS-DOS program needs key combinations such as Alt+Tab and Alt+Enter, you will need to uncheck the relevant boxes on this page. The DOS program will get these keystrokes in full-screen mode or when its window is active, so be prepared to lose the corresponding Windows shortcut.

    It's especially tricky if you uncheck Alt+Enter and the program switches to full-screen mode. You will have to type Ctrl+Alt+Del to open the Task Manager if you want to switch back to the Windows desktop before the program exits.

Figure 9.9. The Miscellaneous Settings tab lets you control the program's use of the mouse and keyboard.


Compatibility Settings

Windows XP compatibility settings let you limit the abilities of the virtual display adapter seen by the MS-DOS program. The relevant settings are Run in 256 Colors and Run in 640x480 Screen Resolution. If your MS-DOS program has problems displaying graphics screens, try checking these boxes.

CONFIG.NT

Just as MS-DOS used CONFIG.SYS to make initial memory allocations and to load device drivers, ntvdm uses CONFIG.NT to configure the virtual DOS environment.

The default CONFIG.NT file as installed by Windows is located in \windows\system32 and contains several pages of comment text, which you may want to read. Here are the default settings in this file:

 dos=high,umbdevice=%systemroot%\system32\himem.sys files=40 

You can edit CONFIG.NT to modify the defaults for all MS-DOS applications, or you can create alternate files using a different name for use with specific applications. In the latter case, use the Advanced button on the Program Settings properties page for the program's shortcut to enter the alternate filename. I'll use the name CONFIG.NT in the discussion that follows to refer to any config file.

Note

For starters, if you use MS-DOS database applications, you will probably want to increase the FILES= setting in CONFIG.NT to 100 or more. You may also want to add the ANSI cursor control module with the line

 device=%systemroot%\system32\ansi.sys 

Other than these two adjustments, it's unlikely that you'll need to make any other changes.


The full set of options for CONFIG.NT is listed in the rest of this section.

COUNTRY= xxx [ , [ yyy ][ , [ path ]] filename ]]

tells MS-DOS to use an alternate character set and date/time format. xxx is a country/region code, yyy is an optional code page designator, and filename designates an optional driver containing country code information. If you use the virtual MS-DOS environment outside the U.S., view the Help and Support Center and search for "country."

DEVICE= [ path\ ] filename [ parameters ]

loads a device driver. Hardware device drivers will almost certainly not work in Windows XP, but certain software services implemented as drivers will. Examples include himem.sys , which is required to let MS-DOS programs access memory above 640KB, and ansi.sys , which interprets character sequences that some DOS programs use to control the cursor. These drivers are located in folder %systemroot%\system32 .

DEVICEHIGH= [ path\ ] filename [ parameters ]

or

DEVICEHIGH [ SIZE = xx ][ path\ ] filename [ parameters ]

similar to device but attempts to load the device driver into upper memory blocks, leaving more conventional memory for MS-DOS applications. If there is insufficient room in upper memory or if the device himem.sys has not been loaded, the driver will be loaded into conventional memory. The alternate size= xx format lets you specify the number of bytes of high memory that must be free; xx must be specified in hexadecimal.

DOS= [ HIGH LOW ][ , UMB NOUMB ]

DOS=HIGH specifies that MS-DOS should move parts of itself into the high memory area (the first 64KB past 1MB). The default is LOW , where DOS resides entirely in conventional memory. The optional keyword UMB indicates that DOS should make upper memory area blocks (the memory beyond 1MB+64KB) available for DOS, devices, and programs.

  DOSONLY  

If this keyword is present in CONFIG.NT, COMMAND.COM will only be permitted to run MS-DOS programs. Normally, if you typed the name of a Windows program at its command prompt or in a batch file, it would run the Windows program in a separate environment. This may disrupt some DOS terminateand-stay-resident (TSR) programs, so the DOSONLY option lets you prevent this from happening.

  ECHOCONFIG  

If the command ECHOCONFIG appears, CONFIG.NT commands are echoed to the Command Prompt window while ntvdm is initializing. The default is for the commands not to be displayed.

  FCBS=   n  

File Control Blocks (FCB) is an archaic structure used by DOS version 1.0 programs to manage files. Few, if any, surviving MS-DOS programs require FCB, but if you have one, you can use the FCBS statement to instruct ntvdm to allocate space for n of them. (At this late date, if you do need them, you'll already know it, as you'll have had to deal with this on every prior version of DOS and Windows.)

  FILES=   n  

sets the maximum number of concurrently open files available to MS-DOS applications. The default value is 20 . You may want to increase this number to 100 or more if you use database applications such as MS-DOS FoxPro.

INSTALL= [ path\ ] filename [ parameters ]

loads a TSR into memory prior to running AUTOEXEC.NT .

One program that you may need to install in AUTOEXEC.NT is setver.exe . Setver intercepts programs' requests to find out what version of DOS is running, and it lies to them. Its purpose is to let you run programs that would otherwise be unhappy to find that they're running on DOS version 5.0, which is what ntvdm would tell them. If your MS-DOS application complains about the DOS version number, open the Help and Support Center and search for "setver."

  NTCMDPROMPT  

By default, when an MS-DOS program is run from the command line or a batch file and exits, cmd runs command.com to handle all further commands. This makes it possible to run old MS-DOS batch files. If you specify NTCMDPROMPT in CONFIG.NT , cmd will not run command.com , but will remain in control between MS-DOS programs. This lets you write modern batch files to use with MS-DOS programs.

SHELL= [ path\ ] filename [ parameters ]

specifies an alternate shell program to use if you do not want to use command.com as the MS-DOS shell. You can also use this command to specify command.com with startup options. For example, the entry

 shell=%systemroot%\system32\command.com /E:2048/P 

requests 2048 bytes for environment variables. The /P option is required to prevent command.com from exiting after processing one command.

  STACKS=   n,s  

When a hardware interrupt occurs, ntvdm needs "memory stack" space to temporarily store information for the interrupt handler. The stacks option lets you instruct ntvdm to allocate separate stack space for interrupt handlers. The numbers n and s instruct ntvdm to allocate n blocks of s bytes each. n can be or 8 through 64 . s can be or 32 to 512 . The default values are 9 and 128 , respectively. If necessary, you can save memory for program use by specifying stacks=0,0 ; this may or may not cause a program crash. You can specify stacks=8,512 to allocate plenty of stack space if you suspect that interrupt handlers are causing DOS crashes.

  SWITCHES=/K  

makes MS-DOS programs treat the keyboard as a "conventional" 96-key keyboard even if it uses the extended 102+ key layout. If you use this switch and also load ansi.sys , specify /k after ansi.sys as well.

The following items are permitted in CONFIG.NT for compatibility with historical CONFIG.SYS settings but have no effect in Windows XP:

  • buffers

  • driveparm

  • lastdrive ( lastdrive is always Z )

AUTOEXEC.NT

AUTOEXEC.NT serves the same purpose AUTOEXEC.BAT did on MS-DOS systems: It is a batch file that lets you run programs that set up the command environment before you begin working. The default version of AUTOEXEC.NT installed with Windows is located in \windows\system32 and contains the following commands:

 lh %SystemRoot%\system32\mscdexnt.exe lh %SystemRoot%\system32\redir lh %SystemRoot%\system32\dosx SET BLASTER=A220 I5 D1 P330 T3 

MSCDEXNT provides support for CD-ROM drives , REDIR is the network interface, DOSX provides upper-memory support (it serves the same purpose EMM386.EXE did on MS-DOS), and the SET command provides DOS programs with information about the simulated Sound Blaster sound hardware. No matter what kind of sound system your computer has, MS-DOS programs "see" a Sound Blastercompatible card (although the emulation is less than perfect).

In addition, if you've installed the Client for Novell Networks, AUTOEXEC.NT will also run nw16.exe and vwipxspx.exe , which give DOS applications access to the Novell application programming interface (API).

You can load other programs and set environment variables in AUTOEXEC.NT , but remember that they will be loaded every time you run an MS-DOS program. If you need particular terminate-and-stay-resident programs only for some MS-DOS applications, set up a customized AUTOEXEC file just for those applications.

Tip

One program that's handy to add to AUTOEXEC.NT is doskey , which gives command.com the same editing commands as those provided by cmd.exe , and in addition, it lets you define abbreviated commands called aliases . To read about this program, start the Help and Support Center and search for "doskey."


MS-DOS Environment Variables

In MS-DOS, memory is a limited resource, and MS-DOS is particularly stingy with environment variable space. If you need to define more than a dozen or so environment variables in any MS-DOSstyle batch files, you'll probably need to extend the amount of space allocated to environment variables either on the Properties dialog box of an associated shortcut or in a shell= command in a CONFIG.NT file. These techniques were described earlier in this appendix.

When you first start an MS-DOS program or command.com , ntvdm inherits the default Windows environment, but with the following changes:

  • All variable names are changed to uppercase. MS-DOS programs do not expect to find lowercase letters in environment variable names.

  • The COMSPEC variable is added, which contains the path and filename of the command shell, usually command.com .

  • The TEMP and TMP variables are reset to the system default, rather than the user-specific setting.

  • Path names in all environment variables are changed to use DOS-compatible 8.3-character names.




Upgrading and Repairing Microsoft Windows
Upgrading and Repairing Microsoft Windows (2nd Edition)
ISBN: 0789736950
EAN: 2147483647
Year: 2005
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net