Failing Script

Advertisement

bbelote
Joined:
Posts:
3
Location:
WY

Failing Script

I've devoured the forums and help topics and I'm still stuck.
Mostly I just end up pulling up the winscp.com prompt after all this. I have a million iterations of trying to get it to work. I'm trying to do this in VBA which is probably where I fall down. Goal is to SFTP a file everynight after a bunch of macros finish running in excel which is why I chose to house it in VBA.
First Iteration
Shell ("""C:\Program Files (x86)\WinSCP\WinSCP.com"" /ini=nul ""/script=c:\Users\John Doe\Desktop\RCGWM1.txt""")
This one doesn't even run the text file.
option batch abort
option confirm off
option transfer binary/s
 
open sftp://user:pass@xxxxxxxxxxx
 
lcd "C:\Users\John Doe\Dropbox\HF\Strat"
cd /UAT/TradeFile/test
 
put "FILL CSV"
Exit

Any help would be greatly appreciated. Like i said, most of my iterations just open up winscp.com command prompt and I can get it to logon but then they don't execute anything.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,034
Location:
Prague, Czechia

Re: Failing Script

It looks good (except for binary/s).

What happens if you execute this on Windows command-line:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul "/script=c:\Users\John Doe\Desktop\RCGWM1.txt"

Reply with quote

bbelote

The script runs if I delete the 'transfer binary' from my script.

My issue is still how do I call CMD in VBA.. and then paste the text for it to run? I start VBA and kick off the macro and I'm left with a blank CMD prompt

Reply with quote

bbelote
Joined:
Posts:
3
Location:
WY

Here is what I'm trying to run in VBA. This just leaves me with a blinking CMD prompt.

Sub CMDandSFTP()
 
Shell ("cmd.exe """C:\Program Files (x86)\WinSCP\WinSCP.com""" /ini=nul """/script=c:\Users\John Doe\Desktop\RCM1.txt""""), 1
 
End Sub

Reply with quote

martin
Site Admin
martin avatar

That command is wrong. I won't work anywhere. First test it on Windows command-line before trying it in VB.

Why cmd.exe? Remove it.

Reply with quote

Advertisement

You can post new topics in this forum