Hello, anyone can help me create a .bat file, which will need to copy a .fdb file from a shared folder on one computer to another share on another pc over my LAN network? The .bat needs to be scheduled as well, is it best to use the windows 7 task scheduler or any specific code in the bat itself to do this?

PS. The .bat needs to be able to overwrite any existing file with same name...

Dani AI

Generated

Short practical summary and example that builds on and : Robocopy is the right tool for a scheduled, reliable LAN copy; schedule the .bat with Task Scheduler but run it under an account that has explicit access to the source and destination shares (don’t rely on a mapped drive). The sample below pulls a single .fdb from a UNC share and forces an overwrite, with retries and logging. (learn.microsoft.com)

@echo off
set SRC=\\SOURCE-PC\Share
set DST=\\DEST-PC\Share
set FILE=yourfile.fdb

robocopy "%SRC%" "%DST%" "%FILE%" /IS /IT /ZB /R:3 /W:5 /NP /LOG+:"C:\Logs\dbcopy.log"

exit /b %ERRORLEVEL%

Notes on the command: /IS /IT include “same”/“tweaked” files so the file is copied even if timestamps/attributes match; /ZB uses restartable mode and falls back to backup mode if needed; /R and /W control retries/wait; /LOG+ appends a run log. Adjust paths, retry counts and the log location to suit your environment. (learn.microsoft.com)

Task Scheduler tips and gotchas: schedule the job to run as a specific user that has read access on the source share and write access on the target share, and give that account “Log on as batch job” if required. If you check “Do not store password” (S4U), the task will run without a stored password but will generally not be able to access network resources — so if the job must touch remote shares, register it with credentials (or use a managed service account). Also avoid drive letters in scheduled tasks: mapped drives are per-session and often not available to scheduled/non-interactive runs — use UNC paths instead. (learn.microsoft.com)

If that .fdb is a live database file (for example Firebird), do not rely on raw file copies while the server is running — use the DB’s backup tools (gbak or nbackup) or stop the DB service first; copying a live DB file can produce an inconsistent/corrupt copy. After you’ve tested the .bat manually, create the scheduled task with the chosen service account, test the scheduled run, and check the robocopy log for exit codes. (firebirdsql.org)

Recommended Answers

All 3 Replies

Yes, the scheduler will work fine. To copy the files securely (with retries and such) I can recommend Robocopy which is available from MSDN somewhere (don't remember which SDK).

So I would also recommend Robocopy. Its included with Windows 7 so you dont have to worry about downloading a copy.

In addition, since you will be reading and writing files to remote systems, you'll most likely need to run the task as a user account that will have the appropriate permissions on the target systems.

thanks for this heads-up

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.