I use this old time-mem utility to measure the execution time of a command from the command line. This is just a c ++ project, the main code here .

I start checking, for the test I run timemem 7z some-err-str . The error is clearly displayed, the code shows 7, this code is returned. But in the batch file, if I immediately echo% errorlevel% after this command, I get 0.

The batch file itself:

timemem 7z some-err-str rem timemem возвращает 7. А выводится на экран 0 echo %errorlevel% 

In general, it behaves the same way as the similar ptime utility.

Why, I have no explanation. And most importantly, how can I fix it?

  • The question is not specific. It looks like "figure out the program for me" .. I think you need to do it yourself. - Vlad from Moscow
  • Yes, the mistake was stupid. I'll fix the cap now. - Yura Shinkarev
  • Only I do not know how to close the question or accept it. - Yura Shinkarev
  • In general, I don’t understand how to make a mistake even in such a small program ... - Yura Shinkarev
  • @YShinkarev: Could you transfer the solution from the question to the answer? (And the answer is to write where the info came from, otherwise it’s so incomprehensible.) - VladD

1 answer 1

The problem was nonsense. In c ++ code , the info () function always returned 0. Namely, the result of this function determines the return code of the program. Changed at the very end of info ()

 return 0; 

on

 return dwExitCode; 

It became correct. Shoot down something else, the correct return code was output to the console, but 0 was actually returned.