onlyforbopi
1/9/2017 - 2:14 PM

WINSCP SCRIPTING GENERAL

WINSCP SCRIPTING GENERAL

WinSCP has two executables:

winscp.exe: Main executable, supports both GUI and console operation;
winscp.com: Console interface tool, supports console operation only, allows input/output redirection.
This follows two basic executable types of Windows operation system, GUI and console.

Both executables are part of the installation package. Both are as well available for portable use.

###

1.
winscp.exe
The .exe executable is the main one.
When run, it starts by default in GUI mode, showing the Login dialog;
Using the command-line options, it can be started in console mode;
It can be used to execute scripts without showing any window (by omitting /console parameter).

winscp.exe /console would pop up in new console window

###

2.
winscp.com
The .com executable is a simple tool that internally runs winscp.exe and provides console interface for it. Its primary purpose is scripting.

What you can do with it:

Supports console mode only, but allows input/output redirection;
When run from another console application (such as standard Windows console/command-line window, i.e. cmd.exe), it inherits its console1).
The .com executable needs the .exe one to operate. It looks for it in the same directory where it is located itself. The .exe must have exactly the same name.

As WinSCP is an Unicode application, you should use a TrueType console font with a full Unicode support, like “Consolas” or “Lucida Console”.

###

Using winscp.com for input/output redirection : 

For input/output redirection use standard operators:

> for output redirection;
< for input redirection;
| for piping.
You can also use input/output redirection when running winscp.com from another application


WinSCP executables return exit code 1 when any command is interrupted due to an error or any prompt is answered Abort (even automatically in batch mode). Otherwise it returns the exit code 0.

To further analyze results of scripted operations, you will find XML logging useful.
winscp.com               : Console/Scripting Mode
winscp.exe               : Consome/Command-line Parameter mode

A.  Script Files
* Commands can be read from a script file, specified with    :  /script 
* Commands can be passed from the command line               :  /command

B.  Encoding of Script Files
* The WINSCP script must always be UTF-8 / UTF-16(with BOM) encoding

C.  Standard Options
    option batch abort = All prompts are answered negatively
    option confirm off = Turn off all confirmations prompts, allow overwites
    
D.  Executables
1. Using_Scripting              :  How to use WINSCP
2. Checking return status       :  How to check if a WINSCP script was succesful
3. Executables                  :  Different executable files of WINSCP and scripting