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

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?
kharoldsenAsked:
Who is Participating?
 
Steve KnightIT ConsultancyCommented:
Personally I prefer to keep the ftp commands all in one, e.g. See my option 3 on my page here:

http://scripts.dragon-it.co.uk/links/batch-ftp-scripting

e.g.

@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:

http://scripts.dragon-it.co.uk/links/batch-password1

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!)

Steve
0
 
pritamduttCommented:
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 http://www.ncftp.com/ncftp/.


Hope this helps.

Regards,
0
 
exponeCommented:
You can download "ncftpget" from here:

http://www.ncftp.com/download/

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"
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
sugunakarCommented:
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"


ftpbatch.txt
0
 
pritamduttCommented:
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.
Regards,
0
 
AlexPaceCommented:
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.
0
 
Steve KnightIT ConsultancyCommented:
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!
Steve
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.