Check Windows

Another good reference for detecting the Windows(r) version is the Assembly Programmers Journal. Here is the issue in question.

Checks to see if in a Windows-DOS session or running in True DOS. Returns version info in DOS' ERRORLEVEL for use in batch files.

Using the DOS Multiplex interrupt, we can see if we are in a Windows-DOS session, or in true DOS.

Please note: If the .PIF file for your program has a check in the "Prevent MS-DOS programs from detecting Windows" check box,
this code will return zero as if you where in True DOS. See the end of this code for another way to detect a Windows DOS box.

Please note: Unknown results with Windows NT versions.
  On return of interrupt 2Fh, ax = 1600h
  (You could also use ax=160Ah, but version is returned in different registers)
  If RC = 0 then - no Windows in system (running in TRUE DOS)
          1 then - found an old version of windows running
        128 then - found an old ver of XMS. Note that XMS does not
                   report on this interrupt anymore. If you want to
                   check for EMS you have to call sub function 160Ah or 1610h
        255 then - found Windows 386 other than version 2.x
            else - found a newer version of windows (RC is version)

*Using in a .bat file
          You can use this in a batch file.
        Example:
                   (Note:  If ErrorLevel is anything other than the
                            five values seen below, this batch file will
                            work incorrectly.  This batch file is used
                            for demonstration only)

                @echo off
                ChkWin
                @if ErrorLevel == 255 goto Win2x
                @if ErrorLevel == 128 goto end
                @if ErrorLevel ==   4 goto Win95
                @if ErrorLevel ==   1 goto OldVer
                @if ErrorLevel ==   0 goto NoWin
                :Win95
                @echo Found Windows 95
                goto end
                :NoWin
                @echo In TRUE DOS
                goto end
                :OldVer
                @echo Found Win 2.x or before
                goto end
                Win2x
                @echo Found a 32-bit Windows
                goto end
                :end

.model tiny
.code
      org   100h

	mov	ax,1600h    ; Check if windows in mem
	int	2Fh         ; Multiplex interrupt
	mov	ah,4Ch      ; exit to DOS
	int	21h         ;  al = ERROR LEVEL

.end                    ; End of assembly code

The above code works great unless the user has place a check mark in the "Prevent MS-DOS programs from detecting Windows" check
box under the Program/Advanced tab in the PIF file of the program.

So here is another way to detect if running in a Windows 9x DOS box even if the above mentioned box is checked.

Please note: Unknown results with Windows NT versions.
.model tiny
.code
           xor  ax,ax         ; point es:di to 0000:0000h
           mov  es,ax         ;  
           mov  di,ax         ;
           mov  ax,1602h      ; Get API entry point
           int  2Fh           ;   call to multiplex interrupt
           mov  ax,es         ;
           or   ax,ax         ; if es:di doesn't point to 0000:0000h
           jnz  short win     ;   then Windows is running a DOS box
           or   di,di         ; else
           jnz  short win     ;   we are in True DOS

           mov  al,'D'        ; so print a 'D'
           jmp  short ($+4)   ; (skip over the 'W' code)
win:       mov  al,'W'        ;
           int  29h           ; print the char
           ret                ; 'return to DOS'
.end

Another note: Some of the Windows NT family versions returned DOS version 5.5.
So if you are trying to detect if Windows NT is running, check for this version. No other DOS version that I know of, returned 5.5.