Hi Everybody,
I have been using dos .bat files to carry out some file management in the background with the batch files being called from within a form's vba module. This is working fine except in one particular scenario.
I send my client an updated version of the front-end via Dropbox. The working front-end, on detecting the new file is present, copies it to the front-end folder with the name of newfile.mdb.
When the user closes the front-end I want the existing application file to be renamed to say oldfile.mdb and the newfile.mdb file renamed to become the new working front-end when the user restarts the program.
It's essential that this happens without direct user involvement. No pressing of buttons.
I have a bat file 'fileswop.bat' with the following lines in it.
REM---------------------------------
TIMEOUT /T15 /nobreak
REN wkgfile.mdb oldfile.mdb
REN newfile.mdb wkgfile.mdb
REM----------------------------------
In the front-end I have a button which opens a 'Do you really want to quit?", MsgBox() that demands a Yes or No. Yes leads to an Application.Quit statement but before that I have this:
Call Shell(Environ$("COMSPEC") & " /c C:\myProg\FileSwop.bat", vbNormalFocus)
Apart from the filename I got everything else off the web.
So before the front-end closes it starts this bat file. I can see that the bat file starts because the dos command window opens briefly then dissapears. I know its not closed because I can hear disk activity at around the 15 second mark, which matches the Timeout /15 instruction. But the filenames just do not change.
If I run the bat file manually even a few seconds after application has closed then it works perfectly well. I concluded that the Dos file cannot rename the application that has just closed because it, the front-end application, is stil in memory. So I increased the Timeout to 30 seconds thinking it just needed more time. I also put the REN statements in a second bat file and after the appropriate Timeout pause called the second file but that didn't work either.
Any ideas folks.
Thanks in anticipation
Rod
p.s. If anyone thinks there's a better group to post this to I would be obliged to hear.
I have been using dos .bat files to carry out some file management in the background with the batch files being called from within a form's vba module. This is working fine except in one particular scenario.
I send my client an updated version of the front-end via Dropbox. The working front-end, on detecting the new file is present, copies it to the front-end folder with the name of newfile.mdb.
When the user closes the front-end I want the existing application file to be renamed to say oldfile.mdb and the newfile.mdb file renamed to become the new working front-end when the user restarts the program.
It's essential that this happens without direct user involvement. No pressing of buttons.
I have a bat file 'fileswop.bat' with the following lines in it.
REM---------------------------------
TIMEOUT /T15 /nobreak
REN wkgfile.mdb oldfile.mdb
REN newfile.mdb wkgfile.mdb
REM----------------------------------
In the front-end I have a button which opens a 'Do you really want to quit?", MsgBox() that demands a Yes or No. Yes leads to an Application.Quit statement but before that I have this:
Call Shell(Environ$("COMSPEC") & " /c C:\myProg\FileSwop.bat", vbNormalFocus)
Apart from the filename I got everything else off the web.
So before the front-end closes it starts this bat file. I can see that the bat file starts because the dos command window opens briefly then dissapears. I know its not closed because I can hear disk activity at around the 15 second mark, which matches the Timeout /15 instruction. But the filenames just do not change.
If I run the bat file manually even a few seconds after application has closed then it works perfectly well. I concluded that the Dos file cannot rename the application that has just closed because it, the front-end application, is stil in memory. So I increased the Timeout to 30 seconds thinking it just needed more time. I also put the REN statements in a second bat file and after the appropriate Timeout pause called the second file but that didn't work either.
Any ideas folks.
Thanks in anticipation
Rod
p.s. If anyone thinks there's a better group to post this to I would be obliged to hear.