I'm under the impression that the errorlevel provided back to command-line level scripting is exactly the value provided by a windows application to its Exit(..) call. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms682658%28v=vs.85%29.aspx

Presumably, an exit call might be called with "-1" as an argument, in spite of the fact that the error code would seem to be an unsigned number.

Does that value get through to a calling command script? (Not that I want it. I need a value which is clearly not a valid error number, and isn't zero).

有帮助吗?

解决方案

@ECHO OFF
SETLOCAL
CALL :negerr 1
ECHO ERRORLEVEL = %errorlevel%
GOTO :EOF

:negerr
EXIT /b -%1

You mean like this?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top