BATCH - Handling nmake errorlevel/return codes

I have an nmake-based project which in turn calls the asp compiler, which can throw an error, which nmake seems to recognize:

NMAKE : fatal error U1077: 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe' : return code '0x1'

However, when I call nmake from within a batch file, the environment variable %ERRORLEVEL% remains set at zero:

nmake /NOLOGO echo BUILD RETURNING: %ERRORLEVEL%

If I control-c the nmake task, I do end up getting a non-zero ERRORLEVEL (it's set to 2) so my assumption is that I'm able to catch errors okay, but nmake isn't bubbling up the non-zero exit code from it's task. Or, at least, I'm mis-trapping it. Any help would be appreciated.

This question and answers originated from www.stackoverflow.com
Question by (11/25/2008 2:18:12 AM)

Answer

First thig, please post your batch file so we see how you trap the error.
Also comment this post so I read again.
As a first git, i'd guess something like:

nmakebatch.cmd usual nmake arguments, without /NOLOGO

@echo off
rem Args[x]: nmake arguments
echo.>> %~n0.log
echo %date% %time%>> %~n0.log
echo nmake /NOLOGO %*>> %~n0.log
nmake /NOLOGO %*
echo %errorlevel%>> %~n0.log

Is a start for trapping all situations, into a incrementing log, while building.

Answer by

Find More Answers
Related Topics  batch  error-handling  dos  nmake  errorlevel
Related Questions
  • ERRORLEVEL inside IF

    Just stumbled into a weird thing with %ERRORLEVEL% and wanted to see if anyone knows why and if there's a way to fix it. Essentially, it seems as if commands executed inside if statements don't set …
  • What is the easiest way to reset ERRORLEVEL to zero?

    I have a post-build event that runs some commands for a c# project. The last command would sometimes cause the ERRORLEVEL value not equils to zero and then the build fails. I want to append an ex…
  • Why does makensis.exe return errorlevel 1 even though it worked?

    I have a NSIS script that works. It compiles, the produced installer works fine. And yet, makensis.exe returns 1 instead of 0. This is a real pain because I use it in a continuous integration setup …
  • Batch ERRORLEVEL results different from CMD?

    Why does ERRORLEVEL behave differently in these two circumstances? From the command line: Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>aescrypt.exe -…
  • Windows batch-file errorlevel question

    I've got a batch file that parses a bunch of file names out of a text file and concatenates them into a single strong - it was previously discussed here . However, I don't want the string to contain…
  • QProcess:exitCode() does not appear to return %errorlevel%

    I am trying to catch specific error codes from a windows command line application run as a QProcess. I had an error today where the application fails: When run on the command line: echo %errorle…
  • Foxit Reader Command Line Arguments (Return Error Codes?)

    Using Foxit Reader through batch file to print PDF files via a FOR loop: SET printing=C:\PDF\Printing SET fox=C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe FOR %%F IN (%printing%\…
  • Errorlevel in a For loop (batch windows)

    I have the following windows batch code: for %%i in (iidbms iigcc iigcd dmfacp dmfrcp rmcmd qwerty) do ( tasklist | findstr /i %%i echo %errorlevel% if %errorlevel% == 0 (echo %…
  • Call URL with wget and return an ERRORLEVEL depending on URL's contents

    A client has a Windows based in-house server, on which they edit the contents of a CMS. The data are synchronized nightly with the live web server. This is a workaround for a slow Internet connectio…
  • How to set ERRORLEVEL in SSIS?

    I have a batch file that runs an SSIS job. I have no knowledge of how the SSIS job runs, I took over a project involving it. The batch file uses %ERRORLEVEL% to detect errors that occur within t…