I found the script to compact the Access DB using VBS script
Just in case sombody's searching
'====================================
' File: CompactDB.vbs
' Author: Q-Built Solutions;
www.QBuilt.com
' Date: 20 Aug. '04
' This script can be used to compact an Access
' database on a Windows 2000 or 2003 server that
' does not have Access installed. This script can
' compact any Microsoft Access database version
' 2000, 2002, or 2003, unless it has a database
' password.
' Windows Script and MDAC 2.1 or higher must be
' installed.
'====================================
Option Explicit
Call getFileInfo
Public Sub getFileInfo( )
On Error Resume Next
Dim sJetCnxn
Dim sDir
Dim sDB
Dim src
Dim dest
Dim fso
Dim ErrDesc
sJetCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data source="
sDir = "D:\my documents\wolseley corporate\db files\" ' Set directory path here.
sDB = "All Canada Inv.mdb" ' Set database file name here.
src = sJetCnxn & sDir & sDB
dest = sJetCnxn & sDir & "Temp" & sDB
Set fso = CreateObject("Scripting.FileSystemObject")
If (Not (fso.FileExists(sDir & sDB))) Then
MsgBox "Database not found:" & vbCrLf & _
sDir & sDB, vbExclamation, _
"Compaction Failure!"
Else
If (fso.FileExists(sDir & "Temp" & sDB)) Then
MsgBox "Previous compaction incomplete." & _
vbCrLf & "Deleting old database.", _
vbInformation, "Compacting . . ."
fso.DeleteFile (sDir & "Temp" & sDB)
End If
ErrDesc = compactDB(src, dest)
'-----------------------------------------------------
' Determine whether compaction was successful.
' When error description = 0, then it's successful.
' Otherwise, textual error description was a failure
' that needs to be reported to the user.
'-----------------------------------------------------
If (IsNumeric(ErrDesc)) Then
fso.DeleteFile sDir & sDB
fso.MoveFile sDir & "Temp" & sDB, sDir & sDB
MsgBox "Compaction completed on" & _
vbCrLf & sDir & sDB, vbInformation, _
"Success!"
Else
MsgBox ErrDesc & vbCrLf & vbCrLf & _
"Compaction failed on" & vbCrLf & _
sDir & sDB, vbExclamation, _
"Compaction Failure!"
End If
End If
Set fso = Nothing
End Sub
Public Function compactDB(ByVal srcDB, ByVal destDB)
On Error Resume Next
Dim jet
Set jet = CreateObject("JRO.JetEngine")
jet.CompactDatabase srcDB, destDB
If (Err.Number = 0) Then
compactDB = False
Else
compactDB = Err.Description
Err.Clear
End If
Set jet = Nothing
End Function