Hi. I have a simple batch file that deletes the current backup copy of the be of the database and then makes a new backup copy of the back end file of the database. The batch file runs perfectly when run from windows explorer. The front end, back end
and batch file are all currently in the same folder of a mapped network drive T:.
@Echo off
cmd /c echo F | del "MyFile - be BACKUP.accdb"
cmd /c echo F | xcopy "MyFile - be.accdb" "MyFile - be BACKUP.accdb"
In the database i've tried creating a Shell command to run the batch file as follows:
Private Sub CopyBackEnd_Click()
On Error GoTo ERROR
Shell "COPYBackEnd.bat"
DoEvents
Exit Sub
ERROR:
MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"
End Sub
I've read as much as i could find about this and have also tried these variations (i also had a go at including the path as the UNC still with no luck):
' Call Shell(Environ$("COMSPEC") & " /c COPYBackEnd.bat", vbNormalFocus)
'Shell "T:\MyPath\COPYBackEnd.bat"
I'm not getting any error message when i run any of the code, the form flashes very briefly and appears to have been successful but the file hasn't been copied.
Can anyone please help me - when i run the batch file from the folder it does work correctly.
Many thanks for any light you can shine.
Cheers, Barb