Share via

Errorlevel lost when passing command to new cmd.exe

Anonymous
2015-10-12T12:26:46+00:00

Hi

When I execute the following commands in a Windows 7 command prompt errorlevel 11 is returned:

%ComSpec% /C "EXIT 11" & IF 1 EQU 2 DIR

ECHO %ERRORLEVEL%

11

If I execute the first command in a new cmd.exe I get errorlevel 0:

%ComSpec% /C "%ComSpec% /C "EXIT 11" & IF 1 EQU 2 DIR"

ECHO %ERRORLEVEL%

0

Why do the two command lines not return the same errorlevel?

Regards,

Michael

Windows for home | Previous Windows versions | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-10-12T13:37:49+00:00

    I have pointed some resources to it

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-10-12T13:07:39+00:00

    Was this answer helpful?

    0 comments No comments