VB-Script: Access-Datenbank komprimieren

JaD

Mitglied
Hallo ihr LIeben,

ich habe ein VB-Script, mit dem ich eine Acces-Datenbank komprimiere.
Eigentlich funktionier das auch prima.
Hier mal das Script:

Code:
  Dim objScript
    Dim objAccess
    Dim strPathToMDB
    Dim strMsg

    ' Get the parameter
    Set objShell = WScript.CreateObject("WScript.Shell")
    
    Set arg = WScript.arguments
    
    ' Set the complete path
    strPathToMDB = arg(0) 

    ' Set a name and path for a temporary mdb file
     strTempDB = "C:\Comp0001.mdb"							

    ' Creat an object 
     Set objAccess = CreateObject("Access.Application")

    ' Repairs and compacts the Database into the temporary mdb file
    objAccess.DbEngine.CompactDatabase strPathToMDB, strTempDB

    If Err.Number > 0 Then
        ' There was an error.  Inform the user and halt execution
        strMsg = "The following error was encountered while compacting database:"
        strMsg = strMsg & vbCrLf & vbCrLf & Err.Description
    Else
        ' Create File System Object to handle file manipulations
        Set objScript= CreateObject("Scripting.FileSystemObject")
    
        ' Copy the compacted mdb by into the original file name
        objScript.CopyFile strTempDB, strPathToMDB, True

        ' Killing the tempfile
        objScript.DeleteFile strTempDB
    End If

    Set objAccess = Nothing
    Set objScript = Nothing

Mein Problem ist jetzt, das ich damit auch Datenbanken auf Rechnern komprimieren möchte, auf denen Access nicht installiert ist.
Gibt es da Möglichkeiten?
Habe selber leider kaum VB-Script Erfahrungen, hoffe jemand kann mir helfen.

Liebe Grüße
JaD
 

Neue Beiträge

Zurück