Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CHECK IF BATCH FILE IS DONE CORRECTLY? 1

Status
Not open for further replies.

franksirvent

Programmer
Mar 8, 2002
358
GB
Hi

I have a daily batch file which runs daily (with Windows task program) automatically.

This batch file opens an Access app. which in turn copies a number of files from different servers.
it then runs a module which compiles all the data from all the files copied, then runs another .BAT file which copies them back to each server once the database is updated.

I need to know if there is someway to 'save' the different steps which the DOS batch file does, so in case there are any problems I can see it (the schedule runs at night, when no one is in the office)

So if I get a message like this:
COPY C:\GLOBAL.MDB Q:\GLOBAL.MDB
file not found

I will then be able to see it and do something about it.

thanks in advance
 
I suggest using VB/VBA and using the inherent file system commands:
Name "C:\Global.mdb" as "Q:\Global.mdb"
Do this in a new .mdb that runs on the scheduler.
Then you can trap, log, alert, etc for file system messages.
--Jim
 
thanks for your fast reply jim

However I am not too sure how this is done...

Within VB if I want to copy a file from V:\mydatabase\testing.mdb to Q:\mydatabase\testing2.mdb

How do I do that from within VB ???

I know how to do a shell DOS command from within VB but not direct commands.

Even then, once done, how do I trap, log, etc ?

Do you have a simple example I can guide with ?

thanks
 
Use the code I showed in the other post:
Code:
Name "C:\Global.mdb" as "Q:\Global.mdb"
You could also use the FileSystemObject, which gives you more objects and properties, much more flexibility. But for simple copying, the Name command works fine.
--Jim
 
great !

i really have never used these commands...i will do a search within Tek-tips to get more ideas on how to do this.

if it works I'll get rid off all my DOS batch files !

thanks Jim !
 
Bah... back when I was in school, we didn't have these fancy VBA commands to do our file maintenance. We wrote huge, complicated batch files and called ourselves programmers.

A quick fix for your batch files while you're investigating the VBA stuff is to put a " > log.txt" at the end of your copy command(s). For example:

Code:
xcopy c:\project1\*.* h:\ > log1.txt
xcopy c:\project2\*.* i:\ > log2.txt

That redirects the output that you'd normally see on your screen to the appropriate text file. You have to use two different names to avoid overwriting the text file.

I do something even simpler on my batch file, I just put a

pause

as the last line of my batch file, which freezes the command window on the screen until I get there to check it out the next morning.

I try not to let my ignorance prevent me from offering a strong opinion.
 
HI BAUDKARMA

thanks for your comments
I am still trying to get to learnt doing it via VB so on the meantime, I will use the system you mention !

I used that system (WRITTING DIRECT TO FILE USING >) years ago but I had forgotten !!!

thanks again !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top