?
Solved

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

Posted on 2006-04-13
5
Medium Priority
?
143 Views
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
0
Comment
Question by:rberke
  • 3
5 Comments
 
LVL 8

Expert Comment

by:Anthony2000
ID: 16449817
have you tried app.EXEName?
0
 
LVL 5

Author Comment

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

xx = App.EXEName

msgbox xx
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 500 total points
ID: 16450575
Like this?


MsgBox GetCurrentlyRunningVbsProgramName

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

Author Comment

by:rberke
ID: 16453031
exactlly! thank you.
0
 
LVL 5

Author Comment

by:rberke
ID: 16488268
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

830 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