You are not logged in.
Hi,
I was unclear if this is the right place to post feedback about the docs. It seems maybe I was supposed to use the guestbook section of the forum, but this section is about the subject which I am actually giving feedback.
I noticed on nt/errorlevel.html that SET is documented as not affecting ERRORLEVEL. When playing with CMD interactively, this does indeed seem to be the case. However, when I write it in a batch file, it seems to reset ERRORLEVEL. I think the documentation should be updated to explain this behavior.
For example, at a prompt:
C:\Users\ohnob>sjfklsdjflksjdflkjsd
'sjfklsdjflksjdflkjsd' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\ohnob>SET x=%ERRORLEVEL%
C:\Users\ohnob>IF ERRORLEVEL 1 ECHO errorlevel1
errorlevel1
If I have a script, though:
C:\Users\ohnob>TYPE AppData\Local\Temp\sldfjlskdfj.cmd
@ECHO OFF
sdlkfjsdlkfsklfjsld
SET x=%ERRORLEVEL%
IF ERRORLEVEL 1 ECHO errorlevel1 0
ECHO %ERRORLEVEL%, %x%
C:\Users\ohnob>CALL AppData\Local\Temp\sldfjlskdfj.cmd
'sdlkfjsdlkfsklfjsld' is not recognized as an internal or external command,
operable program or batch file.
0, 9009
Please let me know if there’s anything I can do to help with updating the documentation. Please also point out to me if I missed something.
I am wondering about the other commands in the “Commands that do NOT affect the ERRORLEVEL:” list too. Haven’t spent time investigating their behavior.
Thanks!
Offline
Good spot, I have tested that and updated the page now.
People tend to post suggestions in this thread: » meta » Pages in ss64.com/nt/ that need update
but it doesnt really matter, also we should probably setup a separate thread for PowerShell suggestions.
Thanks and welcome to the forum!
Offline
Thanks for responding, updating, and going beyond and actually researching the issue more fully!
I looked and was a bit confused at the change at first, but now I see that this is a .cmd versus .bat thing. Interesting!
Your website is a valuable resource which I have used in the recent years and found very helpful. Thanks again!
Offline
Perhaps you may be interested in this topic that explain the %errorlevel% value in a more extensive way...
Antonio
Offline
I have rewritten a couple of parts of the errorlevel page again today to make things a bit clearer - it is a confusing topic.
I've also linked to Antonios helpful SO answer and will probably add some of those exit codes to the individual pages if they arent already there.
Offline