Executing a Batch file.

J

James

I'm trying to execute a bat file from Access 97 in VBA.
I have tried the following statements:

Shell "Z:\GM Wholesale Production Operations
Admin\BAM\SharePoint Archive\Core LFC\LFC Rate
Lock\ZIP_RATE_LOCK.bat"

AND

Dim htask as Integer
Dim BatchFileName as String
BatchFileName = "Z:\GM Wholesale Production Operations
Admin\BAM\SharePoint Archive\Core LFC\LFC Rate
Lock\ZIP_RATE_LOCK.bat"
htask = Shell(BatchFileName, 0) 'Run the Batch File

Both statements do not execute the batch file. When I
double click on ZIP_RATE_LOCK.bat using Windows
Explorer or pasting it in the Run Command, it executes
fine.
 
J

John Nurick

You need to specify a command interpreter in the Shell statement too,
e.g.

Shell "cmd.exe /C ""Z:\blah blah\blah.bat"""
 
G

Guest

Hi James,

I use the following to call a batch file in Access 97:

Call Shell(Environ$("COMSPEC") & " /c C:\access\copyfiles.bat", vbNormalFocus)
 

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