Run a batch file

tacieslik

Registered User.
Local time
Today, 00:41
Joined
May 2, 2001
Messages
244
I'm trying to run a batch file which exists at "c:\sscs\block1\host\hold.bat". I've tried the following code:

Call Shell ("C:\SSCS\block1\HOST\HOLD.BAT", vbMaximizedFocus)

& the RunApp macro command, but I can't get the damn batch file to execute? For about half a second, the dos window appears, but thats it.

I'm using Access 2000 with Windows 2000.


Please let me know of any ideas you guys may have

TIA


Tim C
 
Hello - it may have run but then finished. Are you sure it's not running? Try adding the word "pause" to the last line of your batch file - that will keep it open until you press another key.

Let me know if that works for you.

-Sean
 
Thanks Sean,

I've tried that but it does not work. I also tried running the batch file manually, and it did pause?
I don't know if it's anything to do with this problem, but what it the 'Command Line Arguments" option in 'Tools/Options/Advanced'?

TIA
 
Hi Tim,

Sorry, but I don't know what to tell you! The code looks fine - are you sure you're using the right path? Have you tried running other batch files?

I'm not sure what "Command Line Arguments" is used for, but mine is blank (and I do run batch files from Access).

Let me know if you solve it, good luck!

-Sean
 
Hello Sean,

It would appear that the problem is with Windows 2000. I tried running the batch file from a command prompt and it can't seem to find the file even though it's there.
I've looked on the MS K base, but there are no articles.

I'm at a loss with this one!!
Thanks for trying
 
how would I just open a file or start an application in a command button?
 
I got it to open a program, but how would I get it to open a specific file?
 
Thats a good question. It would help me to know how too!!
 
Run your batch like usual:
Call Shell("C:\z\test.bat")

Your batch file could be something like:
"C:\Report\ImportantReport.doc"

Windows will know what program to open for known file extensions.

Hope that helps!

-Sean
 
Last edited:
Hello All,

I've got the batch file working!! The problem was that access was working from a different directory to the one that my batch file was in. I can't move either files, so I added the command "ChDIR" to my code, hence this:
=====================
Private Sub Command0_Click()

ChDir
Shell "hold.bat"

End Sub
=====================


It all works fine now!!
Cheers
 

Users who are viewing this thread

Back
Top Bottom