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
LVL 5
rberkeConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony2000Commented:
have you tried app.EXEName?
0
rberkeConsultantAuthor Commented:
Is that for vb6? I am using vbs and it does not work.  it says object required 'App'

xx = App.EXEName

msgbox xx
0
vinnyd79Commented:
Like this?


MsgBox GetCurrentlyRunningVbsProgramName

Function GetCurrentlyRunningVbsProgramName()
GetCurrentlyRunningVbsProgramName = Wscript.ScriptFullName
End Function
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rberkeConsultantAuthor Commented:
exactlly! thank you.
0
rberkeConsultantAuthor Commented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.