1.

Solve : ESC give a certain errorlevel ??

Answer»

My main question is. When you use escape to exit a program or SOMETHING. Would that give off a certain ERRORLEVEL? Or would it give of an errorlevel similar to other ones. My second question is. Is it possible to clear variables, so that they can be set again.Quote

My second question is. Is it possible to clear variables, so that they can be set again.

You don't need to, simply give your variable a new value. You can also use set var=, just as you would at the console. You can also reset variables by using setlocal and endlocal in tandem, by restricting the scope of each variable.

Quote
When you use escape to exit a program or something. Would that give off a certain errorlevel?

It should. I believe they are called scan codes. If you need it, I may have a little DOS script that will produce an errorlevel value for every key. That would be great if I had that script. Then a user wouldn't have to press enter to choose an option in a batch file menu .The script is older than dirt. It might even still work.

Code: [Select]A 100
XOR AH, AH
INT 16
CMP AH, 0
JE 100
MOV AL, AH
MOV AH,4C
INT 21

R CX
10
N SCANCODE.COM
W
Q


The last line is purposely left blank. Save the script with a scr extension and from the command line run debug < scriptname.scr to assemble the code.

The ASSEMBLED program is scancode.com. The batch file returns the scancode of the key pressed at the prompt.

Code: [Select]@echo off
echo Enter Key:
scancode
echo %errorlevel%

Good luck. . It didn't work..Quote
It didn't work..

That response is right up there with there is weather outside. How did it not work? When you ran the batch file did you get a prompt? What key did you RESPOND with? What happened next?

Did you copy/paste the script? Did you type it out yourself?

Maybe it doesn't work on Vista. Works OK with XP. Maybe this should have been left in the grave of DOS 3.1

Well, I copy and pasted it into notepad, (I added the blankspace). Then I did from the command line that
debug < scriptname.scr, and it said something like it can't find the file.Quote from: BatchFileCommand on January 27, 2009, 06:37:16 PM
Well, I copy and pasted it into notepad, (I added the blankspace). Then I did from the command line that
debug < scriptname.scr, and it said something like it can't find the file.

Did you save it with the name scriptname.scr in the right folder?

Quote
something like

Love the precision.

in Vista there is no DEBUG That explains that then.I use Vista home premium and i've got debug, and i've just tested the code from Sidewinder and it works fine.

FBweird- it's not on my Vista Ultimate I have on my laptop- is it a separate checkbox during the installation? Or maybe you copied it after install FB?OEM installation, and i don't believe i've downloaded it since installation. THOUGH i've got telnet and that's 'hidden' in vista too. It might be something like that with debug.

FBif they didn't include debug that would have been dumb. "hey, let's remove that silly debug tool! And while we're at it let's give everybody that useless edlin tool from DOS 5!"

I did a dir /s and debug.exe wasn't found on my vista install- so I took the cheap way out and copied it from my XP x64 partition. Not that I ever use debug, though. But on the other hand, I never use my XP installs since they have a few issues I am too lazy to address either...I have Vista Ultimate too. Debuggers not in the extra features either.


Discussion

No Comment Found