Link to home
Start Free TrialLog in
Avatar of Ron Kidd
Ron KiddFlag for Australia

asked on

Run a Batch File from Excel VBA

Hello
I have a procedure that creates a text file with FTP commands and also a Batch file to run the FTP commands.
When I try to run the batch file from VBA I get no FTP action.

I have the OS (Windows XP) on Drive 'C' and My Documents is on another HDD Drive 'G'

When I Run Shell "cmd C:\Shortcuts\FTPit.bat" The CMD Window displays "G:\>"
I get the Same result if I have the VBA file on Drive "G" or Drive "C".
If I double click the bat file it works fine.
If I use start>Run C:\Shortcuts\FTPit.bat It works.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think all you need to do is remove the cmd

Shell "C:\Shortcuts\FTPit.bat"

Open in new window

Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

try:

"cmd /C \"C:\Shortcuts\FTPit.bat\""
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry.  I mix and match a LOT these days.
Avatar of Ron Kidd

ASKER

Tommy
With both of those Solutions I just get a momentry "Flash" and no response from the batch file.
(When I run it from the Run or by Double clicking it the CMD window shows for 30 sec or so and runs through the FTP debugging code)
Put the line
pause
at the end of the batch file and see what happens.

G:\>FTP -d -s:ftpcmds.txt
Error opening script file ftpcmds.txt.

G:\>pause
Press any key to continue . . .

I Changed the batch file to include the complete path to the FTP command file and it now works.
FTP -d -s:C:\Shortcuts\ftpcmds.txt

Thanks for your help