Search code examples
windowsbatch-fileloggingconsolewinscp

How to enable logging in WinSCP script?


I want to logging all information when WinSCP script shows in console to log file. I try to use output redirection, but log file remains empty.

D:\Programs\WinSCP\WinSCP.exe /script=sync.txt > log.txt

Also I tried to add /console parameter, but result is the same.

P.S. Using /log option is not very useful for me, because it write too much incomprehensible information.


Solution

  • winscp.exe is a GUI application. It does not have a standard output that can be redirected.

    For your purposes, there's winscp.com which is a console application. And so it does have a standard output that can be redirected.

    D:\Programs\WinSCP\WinSCP.com /script=sync.txt > log.txt
    

    Read about WinSCP executables.


    You may also be interested in using "reduced" session logging (WinSCP 5.14 and newer only):

    D:\Programs\WinSCP\WinSCP.com /script=sync.txt /loglevel=-1 /log=log.log
    

    Or XML logging:

    D:\Programs\WinSCP\WinSCP.com /script=sync.txt /xmllog=log.xml
    

    Both options can be used with winscp.exe too, but for scripting, it generally makes sense to use winscp.com.