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 40,816 of 42,547    |
|    Tim Meddick to All    |
|    Re: How to displaying error on console w    |
|    06 Dec 13 10:17:31    |
   
   From: timmeddick@o2.co.uk   
      
   Hi, depending how experienced you are with batch-file programming, and also   
   depending exactly what it is you are trying to accomplish - it may be a   
   possible solution is the [exit] command...!!   
    Use the [exit] command (cmd.exe - only) together with the [/b] switch   
   (Type [exit /?] at the prompt for explanation and use of;) will allow you   
   to specify your own ERRORLEVEL at the point of exit - a short example to   
   illustrate the principle is reproduced here....   
      
      
   @echo off   
   if EXIST x:\mypath\myfile.ext goto SUCCESS   
   goto FAILED   
      
   :SUCCESS   
   echo - MyFile is Present -   
   wscript.exe SUCCESS.VBS   
   exit /b 0   
      
   :FAILED   
   echo - MyFile is Absent -   
   wscript.exe FAILED.VBS   
   exit /b 1   
      
      
   However, if it is also part of your query to make some sort of "alert"   
   appear on the desktop to indicate failure, then you could [also] call a   
   simple customised VBScript-file from the batch-file - an example is   
   reproduced below....   
      
      
   'FAILED.VBS   
   'For use with batch files   
   strTitle="BATCHFILE ERROR"   
   Dim WSHShell   
   Set WSHShell = WScript.CreateObject("WScript.Shell")   
   WSHShell.Popup "A specified failure has occurred!" , 5, strTitle   
      
      
    ...obviously, you would also need to create the SUCCESS.VBS file, using   
   the file above to guide you - altering the text for the title and the   
   nature of the message displayed....   
      
   ==   
      
   Cheers, Tim Meddick, Peckham, London. :-)   
      
      
      
      
   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca