Link to home
Start Free TrialLog in
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 rbruce5


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.
Avatar of xThorx

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rbruce5



Bingo!  Thanks for your help - it works perfectly.

Thanks to all who commented