1.

Solve : Need help writing a batch file that copies and overwrites files repeatedly?

Answer»

I'm working on writing a batch FILE for where I work that will help automate some things that have to be done manually.

I work for a retail company that does its credit sales over a network, but when there is a network outage there is a dial-up backup system that can take over and run their credit over dial up.
But this requires the store manager to go on the server and run a few commands through the command LINE - and the obstacles in GETTING them to do this are a real support issue.

I've got the monitoring working, it's copying these files around that is giving me problems.



So here's what I have
credit_working - the currently active file that gives instruction to the credit server
credit_IP - a file stored somewhere else that has instructions for credit running normally over the network
credit_DIAL - a file stored somewhere else that has instructions for credit running over the dial-up modem

- the batch file monitors for a network outage
- when the network goes down
* credit_dial needs to be copied over credit_working

- when the network comes back up
* credit_ip needs to be copied over credit_working
- it goes back to monitoring



The problem I'm having is -
When it goes to copy credit_ip over credit_working, it gives the error message "the system cannot find the file specified"



What can cause this? All the files are do exist and are never being deleted, only overwritten.
I've tried taking the long way around and deleting credit_working, copying credit_ip over, and then renaming it - but it gave the same response.
Any suggestions?
I'll put the affected part of the script in my next post.Here is the part I'm having trouble with.
There's a lot more to it than this, and I'm changing the names and directories for clarity.
I'll put GENERAL STATEMENTS in parenthesis, so assume that all works ok.
Remember, the file credit_working is the one that's actually being used by the credit server.



(The batch file runs all the time and checks for a network connection)
(It has lost connection and goes to :DOWN)

:DOWN
copy "C:\credit_dial.xml" "C:\credit_working"


(goes to monitoring for a connection again)




(After the connection comes back up, it comes to :RESTORED)

:RESTORED
copy "C:\credit_IP.xml" "C:\credit_working"


(goes back to monitoring for a network outage)






It is during :RESTORED that it gives the error message "the system cannot find the file specified"
Any suggestions?Maybe you changed directories. Is the script running with sufficient permissions? I suspect you may need to post a bit more of your code.



Discussion

No Comment Found