shell peculiarities between Windows 9X/NT/2K/XP
January 7, 2003 (as amended)

Running programs in a shell under Windows may be problematic, for a number of reasons, which I outline below:

  1. The name and location of the command shell have changed. Scripts written to call C:\COMMAND.COM must now call C:\WINNT\SYSTEM32\CMD.EXE

  2. The START command has a number of inconsistencies between versions:

  3. NT and 2K support the PATH command, subject to the following (XP untested):

  4. NT, 2K and XP report system information differently to 16-bit DOS programs than they do to a user at a 32-bit command prompt:

  5. The DIR command produces results formatted differently under 9X, NT or 2K (XP untested). In particular, a 16-bit program under NT/2K/XP sees a DOS 6-style directory listing with no LFNs. Under NT/2K/XP a 32-bit program sees an NT-style listing. Under 9X, either a 16- or a 32-bit program both see a FAT32-style listing. Code ported from 16- to 32-bits and run under NT/2K/XP will see a listing different to what it was expecting, and will need to be rewritten or it will fail. Sample listings:

    9X 16-bit DIR output:

    longfi~1 txt         6,893  21/09/05  13:00 longfilename.txt
    

    NT/2K/XP 16-bit DIR output:

    LONGFI~1 TXT        6893 21/09/05   13:00
    

    9X 32-bit DIR output:

    longfi~1 txt         6,893  21/09/05  13:00 longfilename.txt 
    

    NT/2K/XP 32-bit DIR output:

    21/09/2005  13:00                6,893 longfilename.txt
    

  6. NT and 2K do not support DELTREE command, unlike 9X. Use RMDIR /S under NT and 2K. However, the RMDIR command that comes with 9X does not support /S, so a script which must run under both systems must detect which system it's running under, and use the correct command. Use code similar to the below:
    rem --- detecting operating system
    ver | find "Version 4.1" > nul
    if errorlevel 1 goto 98notfound
    set TREEDELCMD=DELTREE /Y
    goto oscheckok
    :98notfound
    set TREEDELCMD=RMDIR /S /Q
    :oscheckok
    %TREEDELCMD% \directory\to\delete
    

  7. NT and 2K do not include the CHOICE utility, unlike 9X. It is in the NT/2K resource kit, however (on 2K, it's in SCRIPTS.CAB). On 2003 it's reportedly an internal command. Scripts executed on NT/2K without CHOICE.EXE from the resource kit will show a "command not found" error before immediately continuing to execute, which may be a problem, depending upon how the script is written.

  8. Under 9X, XCOPY supports copying to the NUL device, while under 2K, it does not (NT/XP untested).

  9. The REGEDIT command produces a text file when exporting under NT or 9X, however under 2K it produces a text file with every second character being ASCII zero (NULL) (XP untested).

  10. 16-bit programs may not start at all, depending on their location in the directory tree. If the full path to the 16-bit executable file is more than 64 characters in length, Windows NT/XP/2K will not execute it. This is by design, apparently.

  11. Long Filename support is not available to 16-bit programs under NT and 2K (XP untested).

  12. 9X's Recycle Bin uses the RECYCLED directory. NT/2K/XP uses a directory called RECYCLER if the drive is formatted as NTFS, or it uses RECYCLED if the drive is formatted as FAT. Software expecting to find the RECYCLED directory will only continue to function after moving to NT/2K/XP if NTFS is not used. If NTFS is used, software will need to be changed, but only for the drives that use NTFS.

  13. NT and 2K do not set the %WINBOOTDIR% environment variable, unlike 9X. Use %WINDIR% instead, as it's supported by both systems (batch files or 32-bit programs only - the %WINDIR% variable is not available to 16-bit programs under either system (see above)). A quick way to have a script support both:
    if "%WINBOOTDIR%" == "" SET WINBOOTDIR=%WINDIR%
    

* Note: to differentiate between NT, 2K and XP with a 16-bit DOS-based program, and work around the identical results problem noted with the VER command, search for the APPDATA environment variable, which, by default, is not found under NT but is found under 2K. A similar technique can be used to differentiate between XP and 2K. XP also has the APPDATA variable where NT does not, however XP has two new variables - CLIENTNAME and SESSIONNAME (both of which reported "Console" on the test system). 2K is missing those two variables, so if your program can't find them, but does find APPDATA you know you're under XP and not 2K. XP is also *missing* the environment variable OS2LIBPATH which was present under 2K.