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.
My statement is as follows:

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

When I double click on ZIP_RATE_LOCK.bat using Windows
Explorer or pasting it in the Run Command, it executes
fine.
 
Shell requires parentheses and a variable. I'd try this:

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


--
--Roger Carlson
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
The bat file might have been executed fine but the DOS
windows disapppeared as soon as it appeared, especially
since you did not specify the WindowStyle argument for the
Shell.

I tested with the following in A2K2:

* Test.bat simply changes a file name.

* Shell "C:\Documents and Settings\vdinh\test.bat"

works fine but I cannot see anything on screen.

* Shell "C:\Documents and Settings\vdinh\test.bat",
vbNormalFocus

works fine, but the DOS window disappears as soon as it
appears.

* To keep the DOS window on screen, I use:

Shell "cmd.exe /K
""C:\Documents and Settings\vdinh\test.bat""",
vbNormalFocus

(typed as one line).

HTH
Van T. Dinh
MVP (Access)
 

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

Back
Top