Calling a .bat file

  • Thread starter Thread starter alex_h
  • Start date Start date
A

alex_h

Guest
Hi,

Is it possible to call a .bat file from an access module. if so how???

If this is not possible does any have any idea's on how to run dos commands from an access module.

any help would be greatly received.

Thanks,
Alex
 
You can call DOS apps and batch files using the SHELL command, like this:

Shell "c:\bats\mybat.bat", vbNormalFocus

But a word of warning: Access will continue to run processes behind the DOS window; if you want to force Access to wait until the batch file has terminated, do this:

-make a little text file called 'notdone.txt' (it doesn't matter what the text file contains, I usually just put the word 'blah' in there, but you might want something like 'please do not delete this file; it is used as part of system x')

-In your batch file, add the following line right at the end:
Copy notdone.txt done.txt

-Then alter your VBA call to the batch file to look like this:

'delete the indicator file if it is already there (like if the app crashed midway last time)
If dir("c:\done.txt") <> "" Then Kill "c:\done.txt"
'start the batch file
Shell "c:\bats\mybat.bat", vbNormalFocus
'wait until the indicator file is copied
While Dir("c:\done.txt") = ""
Wend
'delete the file and carry on as normal
Kill "c:\done.txt"


Hope this helps

Mike

[This message has been edited by Mike Gurman (edited 10-19-2000).]
 
Last edited by a moderator:
I got compiler error on the <&gt. The error says it expects a Then statement.

Can anybody help? Thanks in advance.
 
It was supposed to be <> (VBA for 'Not Equal To')

It looks like a posting error; the HTML was printed instead. I made the changes to his post so that no one else will have this problem again.
 

Users who are viewing this thread

Back
Top Bottom