Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell running a bat file

Status
Not open for further replies.

rollerjk

MIS
May 21, 2001
6
0
0
US
I'm trying to run a bat file using the shell function and it's not working. It opens up the dos prompt then goes away. This is the code:

Shell "c:\smdr\swbdl.bat", vbNormalFocus

Is there something wrong with this or is there another approach I should take? The bat file itself works correctly.

Thank you
 
i would normally do it this way (although i don't think there is a difference)

dim i

i=shell("c:\smdr\swbdl.bat",1)

Nick
 
Thanks Nick. I tried that but didn't get the result I was looking for. I think that would just capture the programs id if the program ran sucessfully.
 
This works for me:

Dim stAppName As String
stAppName = "c:\TestShell.bat"
Call Shell(stAppName,1)

Manny64
 
As far as I remember you need to indicate /command.com if you want to execute BAT files with SHELL.
 
Thanks for the repsonses. The problem wasn't the vba it was in the bat file. When I ran it from vba before I fixed the problem with the bat file it ran so fast that I didn't see that the dos prompt was starting at a different directory than when I pulled up the prompt myself. All I had to do was add a change directory line at the beginning of my bat file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top