Error handle copying file from server

  • Thread starter Thread starter Richhall
  • Start date Start date
R

Richhall

Hi

To ensure I have the latest file for something, when i run a .cmd to
start it, I simply copy the file from a central PC when the .cmd is
run on my PC. (the application is started on a few PCs). The
problem is, it the file is unavailable or the server is unavailable
then the application won't start. What is the best way of handling
this without negatively affecting the startup time too greatly please?

example so far

@echo off
net use J: /d
net use J: \\server\share$
xcopy "J:\server\file1.txt" "C:\Myapp\" /S /Y
net use J: /d /y


Cheers

Rich
 
Richhall said:
Hi

To ensure I have the latest file for something, when i run a .cmd to
start it, I simply copy the file from a central PC when the .cmd is
run on my PC. (the application is started on a few PCs). The
problem is, it the file is unavailable or the server is unavailable
then the application won't start. What is the best way of handling
this without negatively affecting the startup time too greatly please?

example so far

@echo off
net use J: /d
net use J: \\server\share$
xcopy "J:\server\file1.txt" "C:\Myapp\" /S /Y
net use J: /d /y


Cheers

Rich

You could do it like so:

@echo off
ping server -n 2 | find /i "bytes=" > nul || goto :eof
xcopy /s /y /c /d \\Server\Share$\file1.txt" "C:\Myapp\"
 
Back
Top