Batch file to copy files over FTP, script to put file in all users startup

Posted on 2011-10-12
Last Modified: 2012-05-12
I need to create a batch file that will copy a few files down from a FTP server, create a folder on the C drive, and then put the files in the folder.  Next I need they batch file to copy a file to the all users startup folder (differing between XP and windows 7).  Any ideas?
Question by:kharoldsen
    LVL 9

    Assisted Solution

    here are the commands you need to carry out or improvise on:

    mkdir c:\download
    cd /d c:\download
    ncftpget -u <username> -p <password> <remote server> <remote files>
    copy <filename>  "%allusersprofile%\Start Menu\Programs\Startup"

    Open in new window

    NCFtp is an excellent ftp client which downloaded for free from

    Hope this helps.

    LVL 6

    Expert Comment

    You can download "ncftpget" from here:

    as 'ncftpget' is not recognized as an internal Windows command.

    Look under "Download NcFTP Client" and take "NcFTP Client 3.2.5 for Microsoft Windows"
    LVL 3

    Assisted Solution

    you can use the ftp command that comes with windows.
    I added ftpbatch.txt which contains the basic ftp commands to perform your task.
    use that file like following:
    ftp -v -i -s:c:\ftpbatch.txt
    then use below command to copy to startup folder.
    copy a*.* "c:\Documents and Settings\All Users\Start Menu\Programs\Startup"

    So finally the batch file would like following:

    ftp -v -i -s:c:\ftpbatch.txt
    copy a*.* "c:\Documents and Settings\All Users\Start Menu\Programs\Startup"

    LVL 9

    Expert Comment

    Please note that %allusersprofile% environment variable will ensure that you copy the file in correct location across Windows XP/Vista/7 OS.

    %allusersprofile% Environment variable contains the profile path for All Users Profile as required by you.
    LVL 43

    Accepted Solution

    Personally I prefer to keep the ftp commands all in one, e.g. See my option 3 on my page here:


    @echo off
    md c:\somedir
    (echo open x.x.x.x
    echo user username
    echo password pass
    echo lcd c:\somedir
    echo cd /remotedir
    echo bin
    echo get somefile.txt
    echo get another.txt
    echo mget *.txt
    ) | ftp -i -s

    where the get lines can get one file each (as many as you need) and the mget line can get multiple from a dir in one go.

    You can hide the password rather than specifying it in the batch file with a nifty way here:

    As to the copying to shortcut are you planning on doing this as part of a login script (easy like has been said) or remotely pushing to all machines (less easy!)

    LVL 16

    Expert Comment

    It might be a better design to have one server on your network that responsible for fetching the files from the FTP site.  You could have it set up to constantly monitor the FTP site and download any new or updated files.  All downloaded files would be put into a shared network folder.  

    You could make a Scheduled Task and have it run every 5 minutes or you could use Robo-FTP to make a Windows Service that literally polls the site non-stop to instantly grab any changes sends you an email or sms text if there are any connectivity or transfer problems.

    Anyway, your individual PCs will just grab the file from the network share instead of from the FTP site.  If something changes in the future, for example the password of the FTP site, you only have to make the change in one place.  Also this approach is more robust because any users that log in during an internet outtage (or FTP server outtage) will still get the files.
    LVL 43

    Expert Comment

    by:Steve Knight
    Good point there.  I read it incorrectly as he wanted to bring down these files from ftp (issue 1) and then create a file in startup for all users, i.e. on all machines.

    Agreed would be better scheduled to download / script on one machine!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
    SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now