Avatar of rbruce5
 asked on

VB6 - Problem using the shell command to kick off a batch file.


I'm running the following code from a VB6 application -
it's meant to kick off a ftp batch file I've created:

Shell App.Path & "\ftp.bat", vbNormalFocus

I'm using NT 4 and when I run the VB code the DOS window appears for a split second then disappears without executing the commands inside.  The ftp batch file should take around 20 seconds to process.  

If I manually double-click the batch file it works fine.
Any ideas?

Avatar of undefined
Last Comment

8/22/2022 - Mon

I've managed to get my initial problem working.  I used:

Shell "cmd /K" & App.Path & "\ftp.bat", vbNormalFocus

However, there appears to be a long filename issue.  The content of the batch file is:

C:\winnt\system32\ftp.exe -v -s:"C:\Program Files\EPFU Packager\temp\ftp.txt"

 - it uses a text file that contains the ftp commands:

The whole thing works fine if I put my batch file and txt file in a directory with a short filename - e.g., c:\ftptest\, but as soon as I try running it from Program Files\EPFU Packager\ directory it doesn't work.


sometimes command line operationg have problems with directories containing spaces.  e.g. c:\program files\, so it is best to contain them within quotes e.g. "c:\program files\".

you do this within your bat file but not within the VB code, try something like.

Shell "cmd /K """ & App.Path & "\ftp.bat""", vbNormalFocus

Can't guarentee this is your problem without taking a closer look but is a small change and worth a try.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question


Bingo!  Thanks for your help - it works perfectly.

Thanks to all who commented

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy