Auto update of distributed .mde file

Hi there,

While the codes work great in replacing user's frontend version, I noted that the UpdateDbFE.cmd file keeps staying on user's hard drive. Is that normal? I use the same update codes as follows:

Code:
Private Sub UpdateFrontEnd(ByVal LocalFilePath As String, _
                   ByVal MasterFileFolder As String)
 
Dim BatchFile As String
Dim MasterFilePath As String
Dim Restart As String
 
    'Set the file name and location for the file to copy
    MasterFilePath = MasterFileFolder & "\" & CurrentProject.Name
    'Set the file name of the batch file to create
    BatchFile = CurrentProject.Path & "\UpdateDbFE.cmd"
    'Set the restart file name
    Restart = """" & LocalFilePath & """"
 
  'Create the batch file
    Open BatchFile For Output As #1
    Print #1, "@Echo Off"
    Print #1, "ECHO Deleting old file..."
    Print #1, ""
    Print #1, "ping 127.0.0.1 -n 5 -w 1000 > nul"
    Print #1, ""
    Print #1, "Del """ & LocalFilePath & """"
    Print #1, ""
    Print #1, "ECHO Copying new file..."
    Print #1, "Copy /Y """ & MasterFilePath & """ """ & LocalFilePath & """"
    Print #1, ""
    Print #1, "ECHO Starting Microsoft Access..."
    Print #1, "START /I " & """MSAccess.exe"" " & Restart
    Close #1
 
    'Run the batch file
    Shell BatchFile
 
    'Close the current application so batch file can execute.
    DoCmd.Quit
End Sub
 
Yeah, that's normal. If you want to remove it, just put something in your startup routine that checks for it and kills the file if you find it. There's code to that effect already in the CheckFrontEnd function that you can just move and modify, if you want.

Basically, you would put this into your startup routine:
Code:
[COLOR=seagreen]'Check for an already-existing update file, and kill it if it exists.[/COLOR]
If Dir(CurrentProject.Path & "\UpdateDbFE.cmd") <> "" Then Kill CurrentProject.Path & "\UpdateDbFE.cmd"
 
That makes sense. Thank you again for your on-going help and advice.
 

Users who are viewing this thread

Back
Top Bottom