Technology Questions

Go Back   Technology Questions > Software Questions > Operating System Questions > Windows XP

Windows XP Discuss the Microsoft Windows XP Operating System



Reply
 
LinkBack Thread Tools
  #1  
Old 08-25-2007, 09:50 PM
yawnmoth
Newsgroup Contributor
 
Posts: n/a
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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

 
Old 08-25-2007, 09:50 PM
  #2  
Old 08-26-2007, 05:10 AM
HeyBub
Newsgroup Contributor
 
Posts: n/a
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...


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3  
Old 08-27-2007, 02:00 AM
spamsucks@tiscali.co.uk
Newsgroup Contributor
 
Posts: n/a
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
)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
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?

All times are GMT -8. The time now is 09:51 PM.


2003 - 2010 All Rights Reserved. Technology Questions

Search Engine Friendly URLs by vBSEO 3.3.0