Hello All,
I have a script that I use to copy an updated front end from a server to the user's local PC. The script runs when the old front end is opened and detects a new version on the server. The front end closes and calls the script.
All works well UNLESS the front end compacts on close. In that case, I get an error indicated that the old front end cannot be delted (presumably because it is already "open").
How can I modify the script to wait until the front end is done compacting before trying to replace it? Any help is appreciated!
I have a script that I use to copy an updated front end from a server to the user's local PC. The script runs when the old front end is opened and detects a new version on the server. The front end closes and calls the script.
All works well UNLESS the front end compacts on close. In that case, I get an error indicated that the old front end cannot be delted (presumably because it is already "open").
How can I modify the script to wait until the front end is done compacting before trying to replace it? Any help is appreciated!
Code:
Dim strOldPath
Dim strNewPath
Dim FSO
strOldPath=left(wscript.scriptfullname,len(wscript.scriptfullname)-len(wscript.scriptname)) & "dbname.mdb"
strNewPath ="\\server\dbname.mdb"
Set FSO = CreateObject("Scripting.FileSystemObject")
do while FSO.FileExists(Left(strOldPath, len(strOldPath)-3) & "ldb")=True
'As long as an ldb file exists, someone is in the database, so just do nothing until it goes.
loop
'Set WshShell = WScript.CreateObject("WScript.Shell")
FSO.CopyFile strNewpath,strOldPath,True
'wshshell.run stroldpath
msgbox "The newer version has been installed. You may now open the database.", vbinformation, "Database updated."