Executing a Batch file.

  • Thread starter Thread starter James
  • Start date Start date
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.
 
You need to specify a command interpreter in the Shell statement too,
e.g.

Shell "cmd.exe /C ""Z:\blah blah\blah.bat"""
 
Hi James,

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

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