1.

Solve : Exit Command Twist?

Answer»

I am new to command file scripting. What does the "-4" after the exit command do?
Example "Exit -4"

Thanks
You must be running a batch file that looks something like this..

@echo off
:menu
set choice=
echo 1 - menu
echo 2 - exit
set /p choice="enter the number of your choice"
if '%choice%'='1' GOTO :menu
if '%choice%'='2' GOTO :exit

:exit
prompt $P$G



if it is a batch file you can right click it and click edit to view the commands.

anyway the "exit -4" is most likely not a command; just a menu which has echoed to the screen

if it is a command the the -4 would mean nothing as long as there is a space (delimetor) after the exit... the exit command terminates the cmd prompt windowWelcome to the CH forums.

The NUMERIC code SETS the errorlevel to the numeric code specified.. See here.

Ohh yea. those things... ive seen them around....ive got some more reading to do ....


excuse my ignorance. thats why im here.Quote from: Woodman on September 24, 2007, 05:26:43 PM

Welcome to the CH forums.

The numeric code sets the errorlevel to the numeric code specified.. See here.



Thank you! Now I get it. It makes sense because the code should not have gotten here if all went well.

Thank You! hamelinpiper, you have done this at least twice now! Posting a -- long -- answer when you know nothing about the question!

Quote
C:\>exit /?
Quits the CMD.EXE program (command INTERPRETER) or the current batch
script.

EXIT [/B] [exitCode]

/B specifies to exit the current batch script instead of
CMD.EXE. If executed from outside a batch script, it
will quit CMD.EXE

exitCode specifies a numeric number. if /B is specified, sets
ERRORLEVEL that number. If quitting CMD.EXE, sets the process
exit code with that number.



Discussion

No Comment Found