How to start and Access DB from a bat-file

D

DianePDavies

What would the command line be to start a specific Access DB from a bat-fil?
 
P

Paul Shapiro

DianePDavies said:
What would the command line be to start a specific Access DB from a
bat-fil?

Start "YourWindowTitle" "C:\YourDataFolder\YourDB.mdb"

The double-quotes are needed if your arguments contain any spaces, but
including them is ok either way.
 
D

DianePDavies

Now it works with:
"C:\Program Files\Microsoft Office\OFFICE11 \MSACCESS.EXE" "C:\DEMO\A.mde"

However - I would like to place the bat-file in the same folder as A.mde and
then not adress A.mde with a full path - similarly I would like to start
MSACCESS.EXE without a full path.

If I can do that I dont need to worry about the specific location on the
various user PCs. I believe there is a constant for the path to
office-programs... and I would assume it is possible to address A.mde locally?

Any suggestions?
 
S

Stefan Hoffmann

hi Diane,

Now it works with:
"C:\Program Files\Microsoft Office\OFFICE11 \MSACCESS.EXE" "C:\DEMO\A.mde"

However - I would like to place the bat-file in the same folder as A.mde and
then not adress A.mde with a full path - similarly I would like to start
MSACCESS.EXE without a full path.
You always need to specifiy the full path to Access except in one case:

If you don't care which possible installed Access version is used then
you may simply use

Start "C:\DEMO\A.mde"

in your batch.

You may omit the path to the database file, but then your batch does not
work under some circumstances, e.g.

Store your batch under C:\DEMO\Test.cmd with Start A.mde command line.
Open a command line window and switch to the root, C:\.
On C:\ execute your batch:

C:\>\Demo\Test.cmd

This will fail due to the wrong current working directory.


mfG
--> stefan <--
 
D

DianePDavies

Now I have the problem that my batch-file stays open while the database is
open. When I shut down the database the command prompt shuts down too - or if
I click the "x" in the top right corner - but I would like it to close right
after the command to start the database.

How is that done?
 
S

Stefan Hoffmann

hi Diane,

Now I have the problem that my batch-file stays open while the database is
open. When I shut down the database the command prompt shuts down too - or if
I click the "x" in the top right corner - but I would like it to close right
after the command to start the database.
I wonder if you're heading into the right direction with a batch.

What are you trying to achieve? Have you considered using a simple link
instead of a batch?

Maybe you using a front-end update tool like

http://autofeupdater.com/

is what you need.


mfG
--> stefan <--
 
P

Paul Shapiro

What exact command(s) did you use in the batch file? I have many clients
using the Start command that Stefan listed below, and the command window
closes as soon as the call to start the db is processed.

If you're copying the current frontend and then starting it up, there should
be two commands in the batch file:
copy /y "\\MyServer\MyPath\A.mde" "C:\Demo\A.mde"
Start "C:\DEMO\A.mde"
 
D

DianePDavies

If my command looks exactly like you suggest:

start "C:\DEMO\A.mde"

I just open a command prompt with the title "C:\DEMO\A.mde"

If I have the following:

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\DEMO\A.mde"

This starts my database but the command prompt stays open until I close the
databas (or exits the prompt manually by clicking the "x" in the corner).
 
P

Paul Shapiro

Sorry, I think there's a parameter omitted from the Start command.

start "My Window Name" "C:\DEMO\A.mde"

You can get the full documentation for the start command by typing
help start
in a command window.

An excerpt from the help:
Starts a separate window to run a specified program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program]
[parameters]

"title" Title to display in window title bar.
path Starting directory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top