Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 41,783 of 42,547    |
|    Anton Shepelev to All    |
|    Re: A failed output redirection does not    |
|    11 Nov 19 20:18:21    |
   
   From: anton.txt@g{oogle}mail.com   
      
   Herbert Kleebauer to Anton Shepelev:   
      
   > > type a > C:\NOSUCHNDIR\est.txt   
   >   
   > If 'type' isn't executed because of the impossible   
   > redirection, then type can't modify the errorlevel   
   > and it therefore has the same vale as before the   
   > 'type' command. So set the errorlevel to 1 before   
   > the 'type' command. If 'type' is executed and suc-   
   > cessful, then errorlevel is reset to 0 by 'type'.   
   > If 'type' isn't invoked (because of the redirec-   
   > tion error) or is invoked but not successfull   
   > (maybe disk full), then the errorlevel is not 0.   
      
   Understood, thank you very much! So the redirection   
   itself does not affect ERRORLEVEL. But why does the   
   following to:   
      
   @echo off   
   (type a > C:\NOSUCHNDIR\est.txt ) && goto OK || goto ERROR   
   :OK   
   echo All is well.   
   goto END   
   :ERROR   
   echo Error detected.   
   :END   
      
   --   
   () ascii ribbon campaign - against html e-mail   
   /\ http://preview.tinyurl.com/qcy6mjc [archived]   
      
   --- 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