Ron Kidd
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try:
"cmd /C \"C:\Shortcuts\FTPit.bat\" "
"cmd /C \"C:\Shortcuts\FTPit.bat\"
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry. I mix and match a LOT these days.
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)
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.
pause
at the end of the batch file and see what happens.
ASKER
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.tx
Thanks for your help
Open in new window