Computer Hope
Microsoft => Microsoft Windows => Windows NT/2000 => Topic started by: TJ-III on May 17, 2011, 09:24:02 AM
-
1. Does the echo command return an error/exit code?
2. Is there any documentation anywhere that describes the return codes from echo?
3. Does an error from a pipe redirection of echo's output return an error code?
4. Is there any documentation anywhere that describes the return codes from pipe redirection?
Any help, suggestions, or pointers to reference material accepted with thanks.
-
You need to explain what you want.
The 'echo' feature is part of the script used by the command processor. It is not a function or procedure that called by a program.
Have you read this?
http://www.computerhope.com/xdoseror.htm
-
As Geek says, it would be interesting to know what you are aiming for.
Errorlevels are a bit of a mess. This batch shows what I mean.
@echo off
color 00
echo bad: %errorlevel%
ver >nul
echo ok: %errorlevel%
fc/? >nul
echo weird: %errorlevel%
set/? >nul
echo ret: %errorlevel%
(set foo=)
echo ret: %errorlevel%
rem Did not reset the errorlevel?
set foo >nul
echo ret: %errorlevel%
rem So why did this one set the errorlevel?
echo hello | find "egg
echo ret: %errorlevel%
Output (Win 7 64 bit SP1)
bad: 1
ok: 0
weird: -1
ret: -1
ret: -1
Environment variable foo not defined
ret: 1
FIND: Parameter format not correct
ret: 2
-
The example with FIND I showed above is with a malformed (deliberately wrong) FIND syntax (missing quote after search string). The errorlevel (2) is that set by FIND. Otherwise it would have been 0 (string found) or 1 (string not found).