anyone here who can tell me how to make a cmd file return an error code (exit with error) when some condition is met, e.g. a file does not exists, ...
thanx
Put your .EXE or .COM in a batchfile, FRED.BAT or whatever, and on the next line put PAUSE. Then when you run the batchfile it will stop after running the application and invite you to "Press any key to continue...".
to better explain
i'm running that batch from mssql server job and would like not to run the following steps when something goes wrong during the execution of the batch
Ok. Well, as P Andersen (above) suggests, depending upon what comes back from running your prog, maybe the internal ERRORLEVEL response can be used to direct your batch commands to an appropriate "label" within the batchfile. This could then produce a simple menu offering whatever options you want. I.e. Try again, quit, etc. I wrote a simple one in NT4 recently for someone which attempted to make a network connection from his laptop to his main machine and XCOPY some of his files over. If it couldn't make the connection the batch command diverted to a label which typed on screen "No connection to Server" and options to quit, try again etc.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.