< All Topics

Executing a WinSCP Script without a Saved Site

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

WinSCP is an FTP, FTPS, SFTP client that allows managing and transferring files and folders from your FTP site straight from your desktop. WinSCP also offers a scripting interface that users to run a command from a file. Before you start scripting with WinSCP, there are a few things you need to have access to first:

  1. You need to know what your FTP server or Hosted FTP account hostname is. By default, you can use “ftp.hostedftp.com“, or use the changed domain you’ve set up.
  2. You need to know your FTP server or Hosted FTP account username and password. The credentials are required to connect to your server.
  3. You need to be able to run the application notepad as an admin. Administrator rights on your device are necessary to save files in different formats.
  4. You need to have WinSCP installed.

Please note: You need to run note pad as administrator when setting up your script. To setup WinSCP automated scripting, follow the steps below:

Creating your Bash Script

Run your Notepad as administrator

In the notepad, enter the following command: winscp.exe /console /script=script.txt 

The above lets WINSCP know your script file. Save the file name as “script.BAT” in your WinSCP folder. To do this, you need to right-click on your WinSCP application and select Open file location

Save your script.BAT in the WinSCP application folder and Save as type: All Files

Creating your Command Script

Again run the notepad as administrator. In the example script below, we have a login and list all command for more commands please refer to this article. In the notepad, enter the following command below based on your protocol:

Replace username:password with your FTP server or Hosted FTP username and password. If you do not have a Hosted FTP account, replace ftp.hostedftp.com with your FTP server’s hostname.

Protocol Command
SFTP open sftp://username:password@ftp.hostedftp.com/ -hostkey=”ssh-rsa 2048 bc:9d:86:20:2d:68:1a:35:bb:9d:5c:41:f4:eb:69:4c” -rawsettings KEX=”rsa,ecdh,dh-gex-sha1,dh-group14-sha1,WARN,dh-group1-sha1″

ls *

FTPS open ftpes://username:password@ftp.hostedftp.com/ -rawsettings KEX=”rsa,ecdh,dh-gex-sha1,dh-group14-sha1,WARN,dh-group1-sha1″

ls *

FTP open ftp://username:password@ftp.hostedftp.com/

ls *

 

Save the command script as “Script.txt” in the WinSCP application directory. You can double click on the bash script to run and test the connection and commands.

Table of Contents