|
| | |||||||
| Windows XP Discuss the Microsoft Windows XP Operating System |
| | LinkBack | Thread Tools |
|
#1
| |||
| |||
| stopping a batch file when an error occurs? Say I have the following *.cmd file: @echo off cd some_directory cd .. If I run it and some_directory exists, nothing will happen - I'll be in the same directory as before. If, however, some_directory doesn't exist, it'll take me back to the parent directory. My question is.. how can I change this behavior? How can I make it so that if some_directory doesn't exist, it doesn't do "cd .."? Maybe I could do some sort of if statement and do the "cd .." conditionally? |
| |
|
#2
| |||
| |||
| Re: stopping a batch file when an error occurs? yawnmoth wrote: > Say I have the following *.cmd file: > > @echo off > > cd some_directory > cd .. > > If I run it and some_directory exists, nothing will happen - I'll be > in the same directory as before. If, however, some_directory doesn't > exist, it'll take me back to the parent directory. > > My question is.. how can I change this behavior? How can I make it > so that if some_directory doesn't exist, it doesn't do "cd .."? Maybe > I could do some sort of if statement and do the "cd .." conditionally? IF ERRORLEVEL... |
|
#3
| |||
| |||
| Re: stopping a batch file when an error occurs? On 26 Aug, 06:45, yawnmoth <terra1...******.com> wrote: > Say I have the following *.cmd file: > > @echo off > > cd some_directory > cd .. > > If I run it and some_directory exists, nothing will happen - I'll be > in the same directory as before. If, however, some_directory doesn't > exist, it'll take me back to the parent directory. > > My question is.. how can I change this behavior? How can I make it > so that if some_directory doesn't exist, it doesn't do "cd .."? Maybe > I could do some sort of if statement and do the "cd .." conditionally? IF Exist C:\some_directory ( echo yes ) ELSE ( echo no ) |
| Bookmarks |
| Thread Tools | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| IE7 script error occurs but only only 1 user account | bizutch | Internet Explorer | 2 | 05-06-2007 07:37 AM |
| How do you copy a shortcut to a file with a batch file? | Don J | Windows XP | 11 | 04-13-2007 02:00 PM |
| Save batch window msgs to a file from the batch prog | Stephen Rainey | Windows XP | 3 | 01-09-2007 05:15 PM |
| Batch File output to File with java twist | Graza | Windows XP | 7 | 01-04-2007 05:26 AM |
| how to execute batch file automatically when file is added in folder | SANDY | Windows XP | 4 | 01-04-2007 02:48 AM |
| New To Technology Questions? | Do You Need Help with Your Computer or Device? | Do You Need Help with this site? |