< All Topics

Executing a WinSCP Script from a Saved Site

Please note that this is a Hosted~FTP~ resource, scripting support is available to our Enterprise level customers.

WinSCP is a power FTP, FTPS, SFTP client that offers a scripting interface allowing users to run a command from a file. Please note: You need to run note pad as administrator when setting up your script. To setup WinSCP automated scripting, follow the steps below:

Setup WinSCP for Scripting

In the site manager, select what protocol you want to use and input your login credentials for your Hosted FTP account.

Click save and then change the site name to something you will remember. For the sake of this article, we will call it “hostedftp” (optional). Check Save password and click on the ok button. Then log in to make sure all the information entered in the site manager is correct.

Create your Bash Script

Locate the Notepad program. Right-click the program and select Run as administrator. 

Insert the following script: winscp.exe /console /script=script.txt

You need to save the file in the C:\Program Files (x86)\WinSCP. Save the file using the following settings: Save as type: All Files and Filename: script.BAT

Once again, locate the Notepad program. Right-click the program and select Run as administrator. Insert the following script but using your own credentials where necessary:

  1. open hostedftp
    enter your commands after for example ls to list, mget to download multiple files, mput to upload multiple files and so on. (Refer to this article for a list of commands)
  2. Save the file as script.txt in the “C:\Program Files (x86)\WinSCP” directory.
  3. Double click script.bat to run the script.
  4. To test it out, we will be running the script below:

# Connect to the server
open hostedftp
#print Connection successful
echo Connection Successful!___________
#list all
ls *

Table of Contents