My FTP batch script is stuck on "200 PORT command successful" and doesn't upload the files to server

This looks like a typical problem with the FTP active mode. The server cannot connect back to your machine to establish a data transfer connection.

That typically happens as nowadays most client machines are behind a firewall or NAT or both, what prevents the FTP active mode from working. To make the active mode working you need to open your firewall (not recommended) and/or configure NAT routing rules.

See my article on FTP modes and configuring network for the active mode.


Or you use the passive FTP mode. The Windows ftp.exe client does not support the passive mode though, what makes it pretty useless nowadays.

So you need to use another command-line FTP client. A majority of FTP clients do support the passive mode.

For example with WinSCP your runScript.bat would be like:

winscp.com /command ^
    "open ftp://username:[email protected]/" ^
    "cd /public_html/reports/" ^
    "lcd C:\automation\tests\HtmlReporter" ^
    "put *" ^
    "exit"

Note that WinSCP defaults to the passive mode.

For details see WinSCP guides for:

  • Automating file transfers to FTP server
  • Converting Windows FTP script to WinSCP script

(I'm the author of WinSCP)