Run batch file help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
Back
Top