Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
en:docs:cmd:other:cond [2014/05/24 06:54] – valerius | en:docs:cmd:other:cond [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Conditional Commands ===== | ||
- | |||
- | When an internal command or external program finished, it returns a result called the exit code. Conditional commands allow you to perform tasks based upon the previous command' | ||
- | |||
- | If you separate two commands by **&& | ||
- | |||
- | <code winbatch> | ||
- | [c:\] backup c:\ a: && del c: | ||
- | </ | ||
- | |||
- | If you separate two commands by || (OR), the second command will be executed only if the first returns a non-zero exit code. For example, if the following BACKUP operation fails, then ECHO will display a message: | ||
- | |||
- | <code winbatch> | ||
- | [c:\] backup c:\ a: || echo Error in the backup! | ||
- | </ | ||
- | |||
- | All internal commands return an exit code, but not all external programs do. Conditional commands will behave unpredictably if you use them with external programs which do not return an explicit exit code. To determine whether a particular external program returns a meaningful exit code use an **[[ECHO]] %?** command immediately after the program is finished. If the program' | ||