This one beats me completely, but I think this trick by Benny Pedersen is absolutely brilliant, amazing . . .
From: Benny Pedersen Subject: Returns the Errorlevel parameter as hex Newsgroups: alt.msdos.batch Date: 2001-10-04 14:29:46 PST Hi, This batch file returns the Errorlevel parameter as a two digit HEX number but I can't figure out of any purpose so maybe it's useless? Benny Pedersen, @ECHO OFF %COMSPEC% /C rem THIS LINE SET THE ERRORLEVEL PARAMETER = 0d (00h). FOR %%! IN (0 A B C D E F G H I J K L M N O) DO IF ERRORLEVEL %%!0000 SET A=%%! FOR %%v in (00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15) DO IF ERRORLEVEL %A%00%%v SET B=%%v ECHO %A%|CHOICE/c'0ABCDEFGHI'''''''JKLMNO>NUL FOR %%v in (1 2 3 4 5 6 7 8 9 A B C D E F) DO IF ERRORLEVEL }%%v SET A=%%v FOR %%v in (0 1 2 3 4 5 6 7 8 9) DO IF %B%==0%%v SET C=%%v IF NOT (%C%) == () GOTO Result FOR %%v in (0 1 2 3 4 5) DO IF %B%==1%%v SET C=%%v ECHO %C%|CHOICE/c012345>NUL FOR %%v in (A B C D E F) do IF errorlevel H%%v SET C=%%v :Result ECHO. The Errorlevel parameter was %A%%C% (hex) FOR %%v in (A B C) do SET %%v= CHOICE /c THIS LINE SET THE ERRORLEVEL PARAMETER = 255d (FFh) > NUL Message 2 in thread From: Benny Pedersen Subject: Re: Returns the Errorlevel parameter as hex Newsgroups: alt.msdos.batch Date: 2001-10-04 18:06:50 PST "Benny Pedersen" wrote news:dx4v7.17172$lk7.260702@news.get2net.dk... > Hi, > > This batch file returns the Errorlevel parameter as a two digit HEX > number but I can't figure out of any purpose so maybe it's useless? > > Benny Pedersen, @ECHO OFF %COMSPEC%/c rem THIS LINE SET THE ERRORLEVEL PARAMETER = 0d (00h). CHOICE/c THIS LINE SET THE ERRORLEVEL PARAMETER = 255d (FFh) > NUL SET B=F FOR %%! IN (0 A B C D E F G H I J K L M N O) DO IF ERRORLEVEL %%!0000 SET A=%%! FOR %%! in (E D C B A @) DO IF NOT ERRORLEVEL %A%00I%%! SET B=%%! IF @==%B% FOR %%! in (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL %A%000%%! SET B=%%! ECHO %A%'|CHOICE/c'0ABCDEFGHI'''''''JKLMNO>NUL FOR %%! in (1 2 3 4 5 6 7 8 9 A B C D E F) DO IF ERRORLEVEL }%%! SET A=%%! ECHO. Errorlevel %A%%B%h FOR %%! in (A B) do SET %%!=
How about a hexadecimal number for your current drive?
CD | CHOICE /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ >NUL SET B=F FOR %%! IN (0 A B C D E F G H I J K L M N O) DO IF ERRORLEVEL %%!0000 SET A=%%! FOR %%! in (E D C B A @) DO IF NOT ERRORLEVEL %A%00I%%! SET B=%%! IF @==%B% FOR %%! in (0 1 2 3 4 5 6 7 8 9) DO IF ERRORLEVEL %A%000%%! SET B=%%! ECHO %A%'| CHOICE /C:'0ABCDEFGHI'''''''JKLMNO >NUL FOR %%! in (1 2 3 4 5 6 7 8 9 A B C D E F) DO IF ERRORLEVEL }%%! SET A=%%! ECHO. Errorlevel %A%%B%h FOR %%! in (A B) do SET %%!=
page last modified: 2016-09-19; loaded in 0.0017 seconds