Click to See Complete Forum and Search --> : MS-DOS "Exit" command Question


Gary Andrews
08-30-2002, 03:48 PM
Assume that the MS-DOS "EXIT" command is issued in a .bat being executed under Windows 2000.

Microsoft Documentation says the following on their Tech-Net website:

Syntax

exit [/b] [ExitCode]

Parameters
/b
Exits the current batch script.

ExitCode
Specifies a numeric number.

/?
Displays help at the command prompt.

Remarks
If you use /b outside of a batch script, it will exit Cmd.exe.
If you use /b, Cmd.exe sets the ERRORLEVEL to the specified ExitCode. If you exit Cmd.exe, Cmd.exe sets the process exit code with the specified ExitCode.

My Questions:

1. Is the process exit code something different than the ERRORLEVEL code?

2. Say I just completed an XCOPY process unsuccessfully and my errorlevel code is 1. Say I then issue an EXIT command with no operands. Upon exit from that .bat file, will my process code be a 1 showing that the .bat process failed? I am trying to determine if the EXIT command affects the process code when is has no "exitcode" specified.

TIA Gary