2

I wanna know if there is a way to run WinSCP commands like open sftp..., from a batch file, without having to enter commands after WinSCP opens up.

Here's what I wanna happen:

  1. I create a batch file (say demo.bat) that opens WinSCP command-line.
  2. I insert WinSCP commands (open, get, put, etc.) in demo.bat.
  3. The batch file demo.bat opens up WinSCP command-line and executes the commands (get, put, etc.) automatically.
1

1 Answer 1

4

Use /command or /script command-line switches.

There's a guide to automating file transfers to SFTP server with WinSCP.

A simple batch file using /command switch is like:

WinSCP.com ^
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://username:[email protected]/" ^
    "put C:\local\path\file.txt /remote/path/" ^
    "exit"

And WinSCP GUI can actually even generate the batch file for you:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.