Computing.Net > Forums > Programming > Batch Programming: problems on ECHO

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Programming: problems on ECHO

Reply to Message Icon

Name: makinha
Date: July 30, 2007 at 19:58:45 Pacific
OS: win2000
CPU/Ram: 512
Product: IBM
Comment:

Hello All,

I am creating a simple batch file to copy files, log the timestamp and log the copy result. However, I got error when using a program to call this batch file concurrently, it flow an error that "The process cannot access the file because it is being used by another process."

It seems that the ECHO having problem when doing concurrent job. I wondering if there is any command in DOS to do the TRY and CATCH action, or WAIT command to access the file when it is available? THANKS.

MY CODE AS BELOW:
:: BACKUP FILE
@ECHO OFF

ECHO %timestamp% START BACKUP BATCH >> bat.log

SET timestamp=%date:~4,6%%date:~12,2% %time:~0,8%

:SRCFILE
If not exist %1 goto :SRCNO

:BACKUP
copy /y %1 %2
SET msg1= ---Backup File %1 success---
GOTO return%errorlevel%

:SRCNO
SET msg1= ---BACKUP FAILURE: Source File %1 not found---
ECHO %timestamp% %msg1% (error) >> bat.log
EXIT

:return0
ECHO %timestamp% COPY SUCCESS >> bat.log
GOTO end
:return1
ECHO %timestamp% COPY FAILED >> bat.log
GOTO end

:end
ECHO End of batch program



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 30, 2007 at 20:12:13 Pacific
Reply:

Try-catch? No. The closest you could do is:

:loop1
ECHO %timestamp% START BACKUP BATCH >> bat.log || GOTO loop1


0

Response Number 2
Name: worky
Date: July 31, 2007 at 15:17:43 Pacific
Reply:

I have just run into the same problem under a little different circumstances. The file I am logging to gets locked for no apparent reason. I will let you know if I find anything out.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Programming: problems on ECHO

simple batch program www.computing.net/answers/programming/simple-batch-program/12122.html

Batch Programming Append www.computing.net/answers/programming/batch-programming-append/14907.html

problem with batch program www.computing.net/answers/programming/problem-with-batch-program/13148.html