VB Script Help!

ejstefl

Registered User.
Local time
Today, 12:29
Joined
Jan 28, 2002
Messages
378
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!

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."
 
Thanks for the link! Maybe I'm not thinking about this correctly, but I'm not sure how that helps.

My problem is that I close access, and then call the VB Script file. The problem is that if Access is still compacting, the VB Script file won't work.

The attached code will execute an external app, and then wait for it to finish before running the next line of code in Access.

I'm not sure how I can adapt the linked code to help me?
 
wait for compact

This suggestion probably doesn't solve your problem but what if after your dim statements in your vbscript you had it wait, say 30 or 60 seconds, before firing off the vb script that does the replace. Like using something like sleep 60 or in vb.net system.threading.thread.sleep(30000)
 

Users who are viewing this thread

Back
Top Bottom