home bbs files messages ]

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,164 of 68,980   
   Auric__ to Paul Emmons   
   Re: features of DIR   
   23 Feb 18 03:55:25   
   
   From: not.my.real@email.address   
      
   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.   
   >   
   > 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"?   
      
   dir 2>nul   
      
   > Second question: What other commands might now return errorlevel codes that   
   > didn't use to do so?   
      
   It may help to remember that the 9x line was seperate from NT. Dir has   
   *always* returned an errorlevel in NT. If you want to find out what else   
   does, just start experimenting, or script it:   
      
     %*   
     if errorlevel 1 echo YES   
      
   --   
   Back to our regularly scheduled madness.   
      
   --- 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