Using Windows XP Task Scheduler to Automate an FTP Upload - ISInc

I recently came across a problem where I needed to schedule the daily FTP upload of a set of files to one of my client’s FTP servers. I was a bit out of my element and found that locating a solution to this task was surprisingly challenging. I thought I would post the steps here so that someone in a similar situation might benefit from the time I spent in trial and error.

1. My first goal was to make sure I could upload via ftp using the command prompt in Windows XP. I created the following script, ftp_script.txt, which I placed in a scripts folder on the C drive:

put c:\test.txt test.txt

Plug in your corresponding hostname, username, password, and file locations. This script will upload the local copy of test.txt to the server. The above script can be passed into your command line ftp client. Open up your command prompt and type:

ftp -s:path_to_script\scriptfile

Which, in my case, was:

ftp -s:c:\scripts\ftp_script.txt

The “-s” allows you to specify a file name in order to pass your username, password, and put commands to the command line ftp client.

2. If you get Step 1 working, the next step is to create a command file to run the ftp script. The command file is just a text file with a .cmd extension that calls up the command line ftp. In my case, I created ftp.cmd with the contents:

ftp -s:c:\scripts\ftp_script.txt

Test your command file by double clicking it to make sure that it executes the FTP successfully.

3. Finally, create a daily task using the Windows Task Scheduler. Go to Start > Control Panel > Scheduled Tasks (in Classic view). Click Add Scheduled Task and when it prompts you for the application, browse to your command file that you created in Step 2. As you finish out the task scheduler, you’ll get to choose how often you want the task to run and at what time.

After you complete these steps, your ftp job should be ready and waiting for its next scheduled execution time. I hope you find this trick as useful as I did!


  1. nikhil gupta Says:
    November 28th, 2011 at 2:15 am

    open ftp:username:[email protected]_of_server:21
    option batch on
    option confirm off
    option exclude “*.csv”
    option transfer binary
    cd /path of FTP server folder/
    lcd “path of local folder”
    get *.format of the file (for exp: .gz for compressed file,.csv for csv files etc)

  2. […] here so that someone in a similar situation might benefit from the time I spent in trial and error. Share this:TwitterFacebookLike this:LikeBe the first to like this post. Tags automate, courses, […]

  3. THANK YOU VERY MUCH..after trying lots and lots of complicated batch file which never worked on schedule task.Your script saved my life…

  4. Thanks very much for the code. I created the .txt file and ran the ftp command from the command line and it worked perfectly. However, when I created the .cmd file and ran it, a command window opened and started repeating the command from the .cmd file (ftp -s:c:\ftp_script) over and over. I had to ctrl c to get out of it. Any thoughts on what might cause that. I tried it on an XP desktop and Server 2003 with the same result.
    Thanks again.

  5. Update:
    I changed the contents of the .cmd file to:
    http://ftp.exe -s:c:\ftp_script.txt
    and it works.

  6. Glad you got it working Mike.

  7. thank you zach & nikhil this works very well folr me

  8. Thanks for posting.!this will help me with a task I have been assigned to figure out how to get pump logs from a remote location back to home office. Since it is in a remote location I have only dial up. Is there a way to script making a dial up connection and then the FTP then hang up?

  9. I love you man, you are the man!!

  10. Very well explained. It works.
    Thank you,

Leave a Reply