Compact Access Database Via Batch File (Database uses MDW File)
Posted on 2004-09-02
OK, here goes.
I have created the On Timer Event that will close any open databases at 8:30 PM. This works great.
I have batch files that will compact these databases at 8:35 PM.
Contents of batch file:
"C:\Program Files\Microsoft Office\Office\MSAccess.exe" "\\targetserver\databases\database.mdb" /compact "\targetserver\databases\newdatabase.mdb"
Then I just delete the old database and rename the new database to the old.
My problem is that I have one database that uses an *.mdw file.
Normally, the end user clicks on a shortcut on their desktop to access the database and is prompted for credentials.
Contents of shortcut:
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "\\targetserver\databases\database.mdb" /wrkgrp "\\targetserver\databases\mdwfile.mdw"
When I try to run the batch file to compact the database, I get "Database In Use" error.
Do I need to login to compact? I tried changing script to included login credentials, but this will only open the database.
Any help would be appreciative.