Solved Shell call causing Run-time error '5'

dalcazar

New member
Local time
Today, 11:34
Joined
Jul 7, 2021
Messages
6
Hi everyone, I have a piece of code that updates an access front end. It used to run just fine, but it has suddenly started causing a Run-time error '5'. I have made no changes, and I'm able to run the UpdateDbFE.cmd file manually. Can you help me pinpoint what the problem might be? My IT department doesn't seem to have any blocks in place for this, and we made specific exceptions to allow it.

Thanks in advance!

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"
Debug.Print BatchFile
'Set the restart file name
Restart = """" & LocalFilePath & """"

'Create the batch file[/COLOR]
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[/COLOR]
Shell BatchFile

'Close the current application so batch file can execute.[/COLOR]
DoCmd.Quit
End Sub
 
Start by making a manual copy of the master copy of the FE on your computer. Does it work? Copy that file to the client computer. Does it work? MS updates are no always installed at the same time on all computers. If you find a computer that works, compare the version with the computers that don't work and work from there.
 
This is the "invalid procedure call or argument" error. Offhand, from your description, I would look at my References first to see if perhaps a Windows Update screwed one of the DLL files. Look for a broken or missing reference. That would be faster than what Pat suggested - but if there IS no missing or broken reference, then Pat's advice is the best next step.
 
This is solved, and it was a permissions error, not a code problem.

We weren't able to diagnose the problem until I tried running a ShellExecute command as an alternative to the regular shell call. At that point the 'Suspicious Macro Detected' red flag came up and generated a block that could be seen in Defender under the AsrOfficeChildProcessBlocked rule.

Once that was identified, we were able to create an exception for the .accdb file and I'm able to run updates again.
 

Users who are viewing this thread

Back
Top Bottom