Call Shell

B

Boon

Hi,

I want to create a button that will run the batch file.

I used the function Call Shell...

The problem is whent the command prompt windows starts, it starts from the
general path. not from the path where database is located. And thus it
couldn't find the batch file. How can I make the Call Shell function start
from the same path as the database? I want to do this in general too. hard
code the path is not an option here.

Thank you,

Boon
 
S

Stuart McCall

Boon said:
Hi,

I want to create a button that will run the batch file.

I used the function Call Shell...

The problem is whent the command prompt windows starts, it starts from the
general path. not from the path where database is located. And thus it
couldn't find the batch file. How can I make the Call Shell function start
from the same path as the database? I want to do this in general too. hard
code the path is not an option here.

Thank you,

Boon

ChDir Application.CurrentProject.Path
Shell "cmd.exe", 1
 
D

Douglas J. Steele

Less intrusive, append the path to the command being called:

Shell "cmd.exe """ & Application.CurrentProject.Path & "\mybatfile.bat""", 1
 
S

Stuart McCall

Douglas J. Steele said:
Less intrusive, append the path to the command being called:

Shell "cmd.exe """ & Application.CurrentProject.Path & "\mybatfile.bat""",
1
<snip>

Changing the 'current' folder is intrusive?

Also, if mybatfile.bat contains filenames without paths (quite likely), that
will probably fail.
 
D

Douglas J. Steele

Stuart McCall said:
<snip>

Changing the 'current' folder is intrusive?

"Intrusive" in that it can cause other things that used to work to stop
working if they depended on the current directory.
Also, if mybatfile.bat contains filenames without paths (quite likely),
that will probably fail.

True. I'm usually careful to fully qualify my filenames, so that didn't
occur to me.
 

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