Link to home
Start Free TrialLog in
Avatar of Robert Berke
Robert BerkeFlag for United States of America

asked on

How to get the name of the currently running vbs program?


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
end if
Avatar of Anthony2000
Anthony2000
Flag of United States of America image

have you tried app.EXEName?
Avatar of Robert Berke

ASKER

Is that for vb6? I am using vbs and it does not work.  it says object required 'App'

xx = App.EXEName

msgbox xx
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
exactlly! thank you.
Just in case a future researcher reads this:

My front end database referesher didn't work, so don't try it ! ! ! !  

Out of date client databases can sometimes have ClientLastModified >  ServerLastModified.

For instance,  
at 10:00 am Joe on clientCPU01 is using c:\...\FrontEndOrderDatabase
at 10:01 a change is made to \\server01\..\FrontEndOrderDatabase  so LastModifed = 10:01
at 10:10 Joe closes data base, so its LastModified = 10:10
next time joe signs on, he will NOT get his database refreshed.

I think i'll have to build a little database to keep track of the time the last refresh was done.  If I ever get it working, I will post it here.