How to get the name of the currently running vbs program?
Posted on 2006-04-13
ThisName = GetCurrentlyRunningVbsProgramName() < ====== this is the magic function I need
----- details of why I want this magic function -------------
----- 375 bonus points for anyone who can make the following routine actually work. -------------
When I make a change to my MS Access Front End databases during the day, I tell the users to close access, then run a batch file which copies FrontEnd*.mdb files to their local client.
To automate this, I want their desktop shortcuts to point to vbs scripts which does the copy only when the server master copy is more recent that the client copy.
For instance CheckBilling.vbs, CheckOrdering.vbs and CheckAcctRecv.vbs would all have the exact same code:
Const SrvrPath = "\\server01\Prod\"
Const ClientPath = "c:\program files\Prod\"
ThisName = GetCurrentlyRunningProgramName()
DBName = "FrontEnd" & mid(Thisname,6)
Set ServerFile = CreateObject("Scripting.FileSystemObject").GetFile(ServerPath & dbname).FileName)
serverLastModified = ServerFile. DateLastModified
on error resume next
clientLastModified = CreateObject("Scripting.FileSystemObject").GetFile(ClientPath & dbname).FileName).DateLastModified
if err > 0 or clientLastModified < serverLastModified then
kill ClientPath & DBName
ServerFile.copy ClientPath & DBName