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

Posted on 2006-04-13
Last Modified: 2010-05-01

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
Question by:rberke
    LVL 8

    Expert Comment

    have you tried app.EXEName?
    LVL 5

    Author Comment

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

    xx = App.EXEName

    msgbox xx
    LVL 28

    Accepted Solution

    Like this?

    MsgBox GetCurrentlyRunningVbsProgramName

    Function GetCurrentlyRunningVbsProgramName()
    GetCurrentlyRunningVbsProgramName = Wscript.ScriptFullName
    End Function
    LVL 5

    Author Comment

    exactlly! thank you.
    LVL 5

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now