Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS Command needed

Status
Not open for further replies.

sochidog

Technical User
Jun 26, 2003
22
CA
I have a bat file that opens my database. However, if you click it twice, you can open the database twice. What is the dos command to see if access is already running?

"C:\Program Files\Microsoft Office\Office\msaccess.exe" "Y:\OfficeDatabase\xyz.mdb
 
Code:
If Exist "Y:\OfficeDatabase\xyz.ldb" goto endbat
"C:\Program Files\Microsoft Office\Office\msaccess.exe" "Y:\OfficeDatabase\xyz.mdb"
:endbat

Of course, if the database is already in use by someone else, thus a .ldb file exists, you won't be able to get in...



HTH,
Bob [morning]
 
You may use the "/excl" option to open the database exclusively. Check the "Startup command-line options" help topic in access help.

Seaport
 
Thanks bob,
The trick is that its a networked database, which means multiple people in it at once. I just want to prevent the single user from opening two copies of access.
Is there something like this (pseudocode)

If access is already running
skip it
else
fire it up
end if
 
NTMK (Not to my knowledge)

If your database was split to front end - back end and each user had their own copy of the front end on their local drive with a copy of the .BAT file, the batch file would work.

And, response time for each user would improve.

For a lengthy discussion, see this thread: thread958-619535

Please note my knowledge has increased since my contributions there. Also, they refer to Access Projects, but the techniques would apply to plain databases if those databases were split between front-end (forms, reports, etc.) and back-ends (tables, etc.)



HTH,
Bob [morning]
 
Splitting the database is an option for some, but the person who created this app, coded it so that the split would require heavy re-coding. We are upgrading away from access soon anyhow (thank goodness) so there is no point in starting the endeavor.
So i have a shortcut on everyones desktop, that links to a network batch file, to open the database. If they click it twice, two copies. No good - we all know about the corruption probabilities. I will nose around dos commands some more and see if i can find something...
 
The point was to cause the .ldb file to open on each user's local drive - thus, if one exists they have the database open already.

Since you now have one copy of the .mdb file, you also have one copy of the .ldb file. The only way around this is to scan that .ldb file before starting Access and if the current user already has an entry, don't start Access.

There are threads here discussing reading the .ldb file, but that is also not a small undertaking. Plus you'll have to perform the exercise to identify the user.

You're not going to find anything in DOS that will help you. The closest thing to that would be interrogating Windows to find out which tasks are running. Once Access is identified as one of them, you'd then need to determine if that copy of Access is referencing the database in question.

You might be better served by concentrating on the upgrade.


HTH,
Bob [morning]
 
Guess I will have to be content that people will not "double-click" too often. Thank you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top