Compact and Repair with batch file

  • Thread starter Thread starter Peter Fossey
  • Start date Start date
P

Peter Fossey

Mornin' all,

I'd like to make a batch file that compacts and repairs
all the databases I have.

I'm sure there is a command line switch to compact and
repair a database, but I can't remember what it is.

Could someone please refresh my memory and tell me what
the command line would be to do this?

Thanks for your help,
Pete
 
Peter

Just substitute the /decompile with your own switch

C:\Program Files\Microsoft
Office\Office\MSAccess.exe /decompile C:\DB1.mdb

Alastair
 
From the Help file:

/compact target database

Compacts the database specified before the /compact option and then closes
Microsoft Access. If you omit a target database name following the /compact
option, the database is compacted to the original database name and folder.
To compact to a different name, specify a target database. If you don't
include a path in target database, the database is created in your My
Documents folder by default.

You'd use this as

"C:\Program Files\Microsoft Office\Office\MSAccess.exe" "C:\MyDatabase.mdb"
/compact "C:\Backup.mdb"

I STRONGLY recommend you don't try to compact without a target database,
since your database will be hosed if something goes wrong.

What I typically do is rename the database, then compact the renamed
database to the original name. With intelligent renaming, you can keep
backups.
 
Back
Top