How to Switch Windows ftp.exe to Passive Mode (and Upload via curl or wput)
The built-in Windows command-line client ftp.exe works fine until a firewall, NAT router, or remote FTP server demands a Passive data connection and greets your script with: 200 PORT command successful. Consider using PASV.
Many forum posts tell you to run quote pasv (or literal pasv) inside ftp.exe. That is a trap: quote pasv only tells the remote server to enter passive mode, while Microsoft’s legacy ftp.exe client still tries to use Active mode (PORT) and hangs. In short, standard ftp.exe does not support client-side Passive FTP at all.
Fix 1 (Best for Windows 10, 11, and Server). Built-in curl.exe
The good news: starting with Windows 10 (build 1803) and Windows Server 2019, curl.exe is pre-installed in Windows (C:\Windows\System32\curl.exe) – nothing to download. And curl uses Passive FTP mode (EPSV / PASV) by default.
Upload a single file to the root of an FTP server:
curl.exe -T "C:\data\xls\price.zip" -u "ftp_user:ftp_pass" ftp://example.com/
To upload into a specific remote directory, add the folder path after the hostname and always include the trailing slash / (without the trailing slash, curl treats the last path segment as the target filename):
curl.exe -T "C:\pdf\info_RU.pdf" -u "my_login:my_password" ftp://example.com/site/1/
Readers asked in the comments how to upload every file in a folder using curl. A single-line for loop in cmd handles it cleanly (inside a .bat script, double the percent sign to %%f):
for %f in ("C:\data\xls\*.zip") do curl.exe --ftp-create-dirs -T "%f" -u "ftp_user:ftp_pass" ftp://example.com/backup/
The --ftp-create-dirs flag automatically creates the remote directory if it does not exist yet, and if your server uses encrypted FTPS (SSL/TLS), just add --ssl-reqd.
Fix 2. Command-Line wput Utility
Before switching to curl, I used the lightweight console tool wput (the upload counterpart to wget, which also defaults to Passive mode and supports resume).
One quirk with wput: if you run it from one directory while uploading a file from another (such as C:\data\xls\price.zip), it recreates the entire data/xls/ folder tree on the FTP server unless you pass --basename:
C:\Work\wput.exe -v -u -nd --basename=C:\data\xls\ C:\data\xls\price.zip ftp://username:[email protected]/
Fix 3. WinSCP Console (For SFTP or Folder Synchronization)
If you need full folder synchronization or SFTP / FTPS scripting from a batch file, free WinSCP includes a rock-solid console interface that also defaults to Passive mode:
winscp.com /command "open ftp://user:[email protected]/" "put C:\data\xls\*.zip /backup/" "exit"
Forget legacy ftp.exe – for automated uploads from batch scripts, built-in curl.exe -T works reliably in Passive mode right out of the box on every modern Windows installation.
