home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windoware
/
WINDOWARE_1_6.iso
/
winutil
/
inwineq2
/
inwineq1.doc
< prev
next >
Wrap
Text File
|
1991-11-20
|
2KB
|
62 lines
It is frequently desirable for batch files to know whether a DOS program is
running from within a Windows DOS virtual machine or from the DOS prompt
alone. According to Microsoft, it's dangerous to run certain programs, such
as CHKDSK, while you're in Windows. Also, at times you may want to display a
message telling how to switch back to Windows with a hot key.
When Windows is running, it creates an environment variable with the name
`windir' that points to the Windows directory. Normally, one can test for
variables with the `==' operator, but `==' assumes that variable names are all
uppercase, and `windir' is lowercase. (Microsoft probably did this so the SET
command couldn't create or change the variable.) Any reference to `windir' in
a batch file actually looks for a variable named `WINDIR', which isn't the
same thing.
To circumvent this problem, this small assembly language program searches for
`windir'. If it's found, the program returns an ERRORLEVEL of 1; otherwise it
returns an ERRORLEVEL of 0. The following batch file, CHKDSK.BAT, shows how
you can use InWinEQ1 to prevent running CHKDSK from within Windows. First,
put CHKDSK.BAT and INWINEQ1.COM in a directory listed in your PATH command and
rename your DOS directory's CHKDSK.COM to CHKDSK!.COM (depending upon your DOS
version, CHKDSK may be an EXE program). When CHKDSK is typed, the batch file
will check to see if Windows is running. If it is, InWinEQ1 will return an
ERRORLEVEL of 1 and the batch file will go directly to the :INWINDOWS line,
skipping the CHKDSK! command. You can easily modify this batch file for other
purposes.
CHKDSK.BAT:
@ECHO OFF
InWinEQ1
IF ERRORLEVEL 1 GOTO INWINDOWS
CHKDSK! %1 %2 %3
GOTO DONE
:INWINDOWS
CLS
ECHO You cannot run CHKDSK from inside Windows!
:DONE
ECHO ON
InWinEQ1.dat:
N InWinEQ1.com
E100 A1 2C 00 8E C0 BF 00 00 26 8A 05 3C 00 74 25 BE
E110 3D 01 8A 1C 80 FB 00 74 16 26 8A 05 3A C3 75 04
E120 47 46 EB EE 47 26 8A 05 0A C0 75 F8 47 EB D9 C6
E130 06 3C 01 01 B4 4C A0 3C 01 CD 21 00 00 77 69 6E
E140 64 69 72 3D 00
RCX
45
W
Q
To create InWinEQ1.com, input InWinEQ1.dat into DEBUG by typing:
DEBUG < INWINEQ1.DAT
Christopher J. Stein
Durham, North Carolina
published in PC WORLD DECEMBER 1991