#1 27 Mar 2014 20:26

kirch
Member
Registered: 27 Mar 2014
Posts: 2

Error in SS64 documentation?

I would have submitted the following on a "Contact us" page if I could find one, but that didn't happen.
In the SS64 documentation of SETLOCAL ( at ss64.com / nt / setlocal.html ), there seems to be an obvious error. The code snippet that determines whether one is able to invoke enableextensions, which starts with "verify other 2>nul", seems to be using logic that conflicts with the text, which says that Verify will set ERRORLEVEL > 0, and then when "setlocal enableextensions" executes and fails it does NOT set ERRORLEVEL = 1, thus it must remain 0. But the test for failure ("if errorlevel 1 echo Unable to enable extensions") assumes the opposite. Am I missing something? This item has been published at several other sites and remained up for years.

Offline

#2 27 Mar 2014 23:08

kirch
Member
Registered: 27 Mar 2014
Posts: 2

Re: Error in SS64 documentation?

(more) Sorry, the earlier post was a garbled version of a comment left with Microsoft, best not read as its poor transcription caused a new error. I now realize that my issue was with MS's documentation only, not SS64's.
At Technet and other MS pages, they say "...if you use the setlocal command with arguments {enableextensions | disableextensions} or {enabledelayedexpansion | disabledelayedexpansion} and it does not set the ERRORLEVEL variable to one (1), command extensions are not available."
Thus, since we are told that SETLOCAL always sets ERRORLEVEL to something (which I take to mean zero or nonzero), failure = 0 and success = >0.
Elsewhere we are usually told that SETLOCAL sets ERRORLEVEL to 0 if it received a "valid argument", which I assume means one that leads to a success.
The code snippet which this harangue was about (below), seemingly disagrees with the former and agrees with the latter.
Anyway, the SS64 documentation doesn't have the flaw I accused it of and I'm sorry I brought it up.

VERIFY errors 2>nul
SETLOCAL ENABLEEXTENSIONS
IF ERRORLEVEL 1 echo Unable to enable extensions

Offline

Board footer

Powered by FluxBB