Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a scheduled task which executes the commands in my file ftp.txt every day. The file can be seen below, it connects via ftp to my site and puts 3 XML files on to my web server.


ftp -s:filename

File executed by command

open ftp.mysite.co.uk
put C:\file.xml location/file.xml
put C:\file1.xml location/file1.xml
put C:\file2.xml location/file2.xml

I now have to execute the same transfers but to sites with different ftp details. I don't want to schedule a new windows task for each transfer so i was wondering if there is a way to execute other ftp.txt files from the main ftp.txt file that is triggered from the command line? If that is not possible could i just run several ftp batch files from a single command line command.

share|improve this question

1 Answer 1

You could use WinSCP as scripted FTP client.

Scripting functionality of WinSCP does not support any control sequences, manipulation of file paths, etc. If you need these, you have to call WinSCP script from a wrapper script implemented in another scripting language (like VBscript). Any language which supports COM/ActiveX can be used.

Example from the WinSCP site:

<reference object="WinSCP.Session" />
<script language="VBScript">

Option Explicit

' Setup session options
Dim sessionOptions
Set sessionOptions = WScript.CreateObject("WinSCP.SessionOptions")
With sessionOptions
    .Protocol = Protocol_Sftp
    .HostName = "example.com"
    .UserName = "user"
    .Password = "mypassword"
    .SshHostKeyFingerprint = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
End With

Dim session
Set session = WScript.CreateObject("WinSCP.Session")

' Connect
session.Open sessionOptions

' Upload files
Dim transferOptions
Set transferOptions = WScript.CreateObject("WinSCP.TransferOptions")
transferOptions.TransferMode = TransferMode_Binary

Dim transferResult
Set transferResult = session.PutFiles("d:\toupload\*", "/home/user/", False, transferOptions)

' Throw on any error

' Print results
Dim transfer
For Each transfer In transferResult.Transfers
    WScript.Echo "Upload of " & transfer.FileName & " succeeded"

' Disconnect, clean up


Modify such a script to take care of your specific/dynamic needs.

share|improve this answer
I think i may have found a simpler way. I should just be able to extend the ftp.txt file i have. Replacing "bye" with "close" and then starting another ftp session straight after, this way i can use different ftp details and upload the files in different places. –  Tom smith Aug 19 '13 at 21:36
True. But you can also use Scheduler to call single batch file, which would then launch all the required FTP sessions. Such approach will be easier to manage, it may also allow you to launch concurrent sessions with 'start' command, were there such need and the files large. –  Michał Sacharewicz Aug 19 '13 at 22:14
Have in mind that FTP automations typically need some error checking. A linear script either works or fails. If you start dozens of scripts, it could be very hard to find what went wrong. Another potential problem is security. The FTP protocol transmits passwords in clear text without encryption. That can be avoided using SFTP. –  Axel Kemper Aug 20 '13 at 6:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.