i am trying to write a bat file on windows xp. I can connect ftp server and download files by console but i can't make it work by unattended bat file.

ftp //connect server but ask username and password manualy how can i connect autamticly with password ?

i have tried ftp pass pass but doesn't work. all commands here

  • /* Missing tag: windows */
    – Vi.
    Commented Jul 6, 2010 at 15:52

4 Answers 4


Save this as a batch file and run it

echo user  >> ftpcommands.txt
echo myusername>> ftpcommands.txt
echo mypassword>> ftpcommands.txt
echo get file1>> ftpcommands.txt
echo get file2>> ftpcommands.txt
echo quit  >> ftpcommands.txt
ftp -n -s:ftpcommands.txt ftp.example.com
del ftpcommands.txt

I tend to avoid batching with vanilla windows FTP. I recommend trying out WinSCP: It's free, it's got robust scripting capabilities, and it's got a lot more features than the default FTP client that comes with Windows.

  • Honestly i just interested in native windows scripting more.
    – Freshblood
    Commented Jul 6, 2010 at 17:38

Try the -s:script.txt method of scripting, as described here. Basically, you create a script file like this:

get file1

And invoke it like so:

ftp -n -s:script.txt ftp.example.com

  • but problem is we are using 2 files so i have to always send 2 file there and this is what i don't want. I can do all my job by command line but i cant make unattended batch file yet :{
    – Freshblood
    Commented Jul 6, 2010 at 18:17

Best solution is write commands into text file then send that text file as parameter.

echo user nod32 nod32 >ftp.txt

echo get my.text d:\my.txt >> ftp.txt

echo cd Books >>ftp.txt

ftp -n -s:ftp.txt localhost

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .