LarrySteeze
LarrySteeze

Reputation: 43

Compare File Versions With Batch Script

I've created an Access database to be shared through the entire department, which I've split into a front end and a back end. Unfortunately, there's no easy way I can figure out to ensure all users are consistently using the newest version of the front end on their local machine as I add requested updates.

To overcome this, I created an install batch script that creates a shortcut on their desktop. as well as nesting the front end and an "update" batch script in a custom folder on their PC. The shortcut actually links to the "update" batch script, which then downloads the newest version of the front end (overwriting the existing one), then loads it.

Ideally, this would not download it every time and instead only downloads it if the version of the front end on the network is greater than that on the local machine. Unfortunately, I can't seem to figure out how to do this with an accdb file (though I've seen information for executable files). We are using Access 2010 and an Access 2007 filetype. I still have not figured out how to append a version number to the front end, but I'm open to including a text file as well simply to store that version number. Any suggestions?

Below is the script I currently have for the update file.

@ECHO OFF
CLS
XCOPY "\\NetworkPath\Install\*.accdb" c:\Reserved\Database /y /q
XCOPY "\\NetworkPath\Install\Update.bat" c:\Reserved\Database /y /q
CLS
ECHO Starting database...
START "" "C:\Reserved\Database\FrontEnd.accdb"

Upvotes: 3

Views: 1266

Answers (1)

Yawar
Yawar

Reputation: 11627

I've done the exact same thing, and solved the problem of only re-downloading the frontend when it has changed by using the xcopy command with the /d switch:

xcopy /yqd \\network\frontend.accdb frontend.accdb

Xcopy reference: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true

That works, but leaves a small gap in the logic: when someone is using their local copy of the frontend, and you push a new version to the network, and then they exit the frontend and run the script again: it won't download the new version because the user's local copy will have a later modification time.

To overcome this, I actually make a copy of the local frontend and start that from the script, instead of starting the downloaded copy. That way the downloaded copy retains its original modification time and xcopy's time check works correctly. You do have to train your users though to ignore the local copies of the accdb file and only use the script.

Upvotes: 2

Related Questions