WAD 4DOS and benny.bat

Nov 2, 2008
231
2
You probably do not know of this ancient DOS bug, and it probably does not matter much nowdays, but all versions of command.com (except freedos), support an interesting bug as given in the following batch. 4DOS, 4OS2 and 4NT do not, but you can always include a different test for it.

Code:
@ECHO OFF
::  Benny Penderson, "Hex-Hax" of the year of the Lord, 19:0 .
choice /n /cABCDEFGHIJKLMNOPQRSTUVWXYZ Choose drive:
:  FINDCD
FOR %%D IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF ERRORLEVEL H%%D SET DRIVE=%%D
ECHO You chose drive %DRIVE%

FOR %%D IN (a b c d e f g h i j k l m n o p q r s t u v w x y z) DO IF ERRORLEVEL x%%D SET DRIVE=%%D
ECHO You chose drive %DRIVE%

Basically, it sets the error code to CHR$(D)-48, and treats the number modulo 100. The above code returns A or a if selected for 1, B or b if 2 is selected.
Hex Hax is a reminder for the upper and lower case letters, and the 19:0 is 2000 as "19"+CHR$(tens+48)+CHR$(units+48)
 
Similar threads
Thread starter Title Forum Replies Date
M How to set Path variable for non-executable file extensions in 4DOS Support 8
C released first product (4DOS) in 1989 Support 6
M Free version of 4Dos? Support 5
Joe Caverly @select like 4DOS Support 1
I Relationship to 4DOS Support 4
K_Meinhard 4DOS attached to TC Support 1
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
M Problem with VSDevCmd.bat in VS 16.7.3 Support 0
Joe Caverly .BAT works in TCC-RT 25, but not in TCC-RT 26 Support 4
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
I BTM slower than BAT? Support 14
S incorrect message at start Cancel batch job 4START.bat ? (Y/N/A) : Support 1
S Debugger Bat file call history Support 9
E How to? use Executable Extensions: .bat and .cmd Support 8
P MS VS2013 vsdevcmd.bat fails to run with tcmd 17 x64 Support 10
I How to? Bat Works but BTM Doesn't Support 6
C Documentation .CMD .BAT .BTM Support 15
A Stupid, obvious question - launch a BAT with TC Support 10
Mordachai How to get a TC interface instead of a console for .btm, .bat, ? Support 10
A WAD BOM printed on command line from BAT file Support 5
C Simple .bat question - dump contents of 2 dimensional array Support 2
C .bat files works in cmd.exe, not in TCMD Support 6
CWBillow TCC and CMD / BAT files Support 3
C .CMD .vs. .BAT Support 3
B Strange handling of a .BAT file Support 5
Roedy bat file properties Support 1

Similar threads