Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,166 of 68,980    |
|    JJ to Paul Emmons    |
|    Re: features of DIR    |
|    23 Feb 18 19:00:44    |
      From: jj4public@vfemail.net              On Fri, 23 Feb 2018 01:01:40 GMT, Paul Emmons wrote:       > I just discovered that, in Windows-XT, DIR returns errorlevel 1 if no files       > are found corresponding to the specifications submitted. (This is not true       > in Windows 98). I was about to kick myself for not knowing this long       > since, but the help for DIR does not document this useful feature.              ERRORLEVEL is originally designed to provide access to the exit code of a       program (i.e. external command). But later, either since Windows NT 3.x or       4.0, some internal commands also generate an exit code.              Microsoft tend to remove old information, even though the information still       applies to newer software versions. The documentations in Windows NT 3.x or       4.0 probably contains more details about CMD.EXE, then the ones in Windows       2000 and newer versions.              > In this case, "File Not Found" is displayed, presumably on the device       > STDERR. If the output of DIR is redirected to a file, this message does       > not appear in the file.       >       > My first question: I am using DIR in a batch file and am handling the file-       > not-found condition by means of the errorlevel. Is there a way to suppress       > the display of the message "File Not Found"?              You'll have to redirect the STDERR handle as mentioned by Auric_.              > Second question: What other commands might now return errorlevel codes that       > didn't use to do so?              Most internal commands which have the possibility of causing an error due to       not finding something from the given parameter, will generate an exit code.       e.g. CALL, CD, DEL, FOR, FTYPE, GOTO, PUSHD, TYPE, VOL, etc. But since at       least one command generates an exit code only if a specific parameter is       used (e.g. SET /P), other commands may do it too.              While you can create a batch file to check each and every command       parameters, IMO, it would be a pretty large project - considering that there       are many command parameters in total.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca