[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • Last Modified:

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
0
p-plater
Asked:
p-plater
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
TommySzalapskiCommented:
Shouldn't you just run this?
Shell "C:\Shortcuts\FTPit.bat"
0
 
ScriptAddictCommented:
I think all you need to do is remove the cmd

Shell "C:\Shortcuts\FTPit.bat"

Open in new window

0
 
slightwv (䄆 Netminder) Commented:
try:

"cmd /C \"C:\Shortcuts\FTPit.bat\""
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
TommySzalapskiCommented:
slightwv, that's C++ syntax. For VBA it would be
Shell "cmd /C ""C:\Shortcuts\FTPit.bat"""

Both that and my first solution work fine for me.
0
 
slightwv (䄆 Netminder) Commented:
sorry.  I mix and match a LOT these days.
0
 
p-platerAuthor Commented:
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)
0
 
TommySzalapskiCommented:
Put the line
pause
at the end of the batch file and see what happens.
0
 
p-platerAuthor Commented:

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
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now