Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

WAD 4DOS and benny.bat

Nov
247
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

Back
Top