Run batch file help

G

Greg Snidow

Greetings all. I am having a hard time trying to get a batch file to run
properly from a command button. I have tried:

Shell "cmd /k ""C:\YourBatchPath\YourBatchFileName.bat""", vbNormalFocus

as posted by Daniel a few weeks ago, but I keep geting errors. I have tried:

Dim strCmd As String
strCmd = """C:\Program Files\Folder\Application.exe"" -a -b99"
MsgBox strCmd
Shell strCmd
as posted here this time last year to no avail. I have tried the solution
at http://www.mvps.org/access/general/gen0015.htm, but all it does for me is
open a command promt then close it. I have tried searching on google for "run
batch from Access", but there is not a solution that seems to work for me.
If my file path is C:\documents and settings\all users\desktop\test.bat what
is the simplest way to get access to open this file? Thank you for any and
all help.
 
J

John Nurick

Hi Greg,

If you type this in the Immediate pane and hit enter, do you get a
command prompt?

Shell Environ$("COMSPEC") & " /K", vbNormalFocus

And if you type this at the command prompt

"C:\YourBatchPath\YourBatchFileName.bat"

does it run your batch file?

If so, this

Shell Environ$("COMSPEC") & _
" /C ""C:\YourBatchPath\YourBatchFileName.bat""", _
vbNormalFocus

will launch the command interpreter, run the batch file and then close
the window.

Make sure the batch file provides some feedback: for instance you could
temporarily insert something like this
ECHO I'm in the batch file!
PAUSE
 

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