Run WinSCP from a Windows Batch File: Reliable SFTP Automation


Publication Date:

Updated:


INFORMATION > Run WinSCP from a Windows Batch File: Reliable SFTP Automation

Bottom line: Call the console executable WinSCP.com, pass a version-controlled command script that contains no secret, quote every Windows path, and return WinSCP's exit code to Task Scheduler or CI.

What you'll learn

  • The separation between a .bat launcher and WinSCP's own command script.
  • How to capture session logs and make failures visible to automation.
  • How to avoid fragile current-directory assumptions and embedded passwords.

Who this is for: Windows users moving a manual WinSCP session into Task Scheduler or another unattended runner.

2026 context: The basic console workflow remains supported. Apply the current WinSCP syntax for host-key pinning and credentials rather than copying an old interactive acceptance prompt into an unattended job.

Overview

This is about how to run WinSCP in batch. WinSCP is often operated via GUI, but it can also be run as a batch.

Check the WinSCP download folder (e.g. "C:\Program Files (x86)\WinSCP") and you will find the "WinSCP.com" file. By calling this file from the command prompt, WinSCP can be executed as a batch.

Table of Contents

  1. How to operate as a batch
  2. How to create a batch file
  3. Conclusion

1. How to operate as a batch

Create a batch file with a .bat extension so that WinSCP runs by simply double-clicking the batch file.

2. How to create a batch file

To run WinSCP in batch, two files are required: a "bat file" to invoke WinSCP in batch from the command prompt and a "txt file" to execute WinSCP commands.

The related WinSCP automation example combines these commands into batch files for uploads and downloads.

How to create an automatic file download and upload tool using the WinSCP command

3. Conclusion

WinSCP scripting can automate repeatable transfers. Store credentials outside scripts, pin and verify the host key, log failures, and test retry behavior before scheduling a job.

Official references