This is an old revision of the document!

How do I configure session, transfer and/or any other settings for which there are no script commands?

Generally the solution is to configure the settings in GUI. Script will in the most cases use the preconfigured settings as default one. For session settings, in the latest beta release, preferred solution is to use -rawsettings switch.

If you want to make your configuration portable, you can save it into an INI file and distribute the INI file with your script.

If the value of the option is not static you can generate the INI file before running the script. See examples below.

Advertisement

You may want to set the INI file read-only, to prevent WinSCP writing to it, when exiting.

Session Settings

For session settings, you can use -rawsettings switch or open command (This feature is available only in the latest beta release.) or pre-configure a stored session with all your settings from GUI and open that stored session using the open command.

Using -rawsettings Switch

This feature is available only in the latest beta release.

For example to open session with enabled HTTP proxy use following command:

open <session_url> -rawsettings ProxyMethod=3 ProxyHost=proxy ProxyPort=8080

Using Stored Session

For example to enable HTTP proxy use following INI file:

[Sessions\mysession]
HostName=example.com
UserName=customer
ProxyMethod=3
ProxyHost=proxy
ProxyPort=8080

Advertisement

Then, providing the INI file is found and loaded by the WinSCP process running the script, you can use command “open mysession” to open the pre-configured session.

You can even make a batch file that generates the INI file dynamically based on current context. For example to use value of environmental variable as proxy host name use following batch file:

echo [Sessions\mysession] > server.ini
...
echo ProxyHost=%PROXYHOST% >> server.ini
...
winscp /console /script=example.txt /ini=server.ini
del server.ini

Syntax and Examples

See raw session settings syntax.

Transfer Settings

For transfer setting, you can pre-configure your preferred settings as default transfer settings. The script uses the default transfer settings as initial.

Examples

You can use INI file using following syntax: For example, to configure changing case of filenames to lowercase during transfer, use following INI file:

[Configuration\Interface\CopyParam]
; File name case modification (1 = Upper case, 2 = Lower case, 4 = Lower case 8.3)
FileNameCase=2
; Transfer resume/Transfer to temporary file names (0 = All files, 1 = Files above threshold, 2 = Disabled)
ResumeSupport=0

Other Settings

The same applies to most other settings, such as configuring reconnect interval:

[Configuration\Interface]
SessionReopenAuto=10000

Last modified: by martin