Call Shell

  • Thread starter Thread starter Boon
  • Start date Start date
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
 
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
 
Less intrusive, append the path to the command being called:

Shell "cmd.exe """ & Application.CurrentProject.Path & "\mybatfile.bat""", 1
 
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.
 
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.
 
Back
Top