Differences

This shows you the differences between the selected revisions of the page.

2014-08-27 2014-08-27
since windows vista, shortcut cannot point to .com files (martin) batch file syntax highlighting (martin)
Line 39: Line 39:
Use the ''/script'' [[commandline|command line]] option to pass the script to the WinSCP [[executables|executable]]. You can embed the complete command line into a Windows batch file (''.bat''), like as follows: Use the ''/script'' [[commandline|command line]] option to pass the script to the WinSCP [[executables|executable]]. You can embed the complete command line into a Windows batch file (''.bat''), like as follows:
-<code>+<code batch>
@echo off @echo off
winscp.com /script=myscript.txt winscp.com /script=myscript.txt
Line 76: Line 76:
Execute the above script using syntax: Execute the above script using syntax:
-<code>+<code batch>
winscp.com /script=script.tmp /parameter c:\myfile.txt winscp.com /script=script.tmp /parameter c:\myfile.txt
</code> </code>
Line 86: Line 86:
Following example shows batch file that takes filename on command line and generates WinSCP script file to upload that file to remote server: Following example shows batch file that takes filename on command line and generates WinSCP script file to upload that file to remote server:
-<code>+<code batch>
rem Generate temporary script to upload %1 rem Generate temporary script to upload %1
echo option batch abort > script.tmp echo option batch abort > script.tmp
Line 103: Line 103:
Now you can run the batch file like (supposing you have saved it to file ''upload.bat''): Now you can run the batch file like (supposing you have saved it to file ''upload.bat''):
-<code>+<code batch>
upload.bat c:\myfile.txt upload.bat c:\myfile.txt
</code> </code>
Line 121: Line 121:
Once you find out what was the result of the script, you can perform any action you like. E.g. after evaluating exit code of WinSCP, you can send a "success" or "error" email. For that use any command-line email client you like, e.g. [[http://glob.com.au/sendmail/|sendmail]]((When installing sendmail, you can ignore all references to ''/usr/lib/'' (or ''c:\usr\lib'') directories in its installation instructions, as you will be running ''sendmail.exe'' directly from a Windows batch file. Just place sendmail files to any convenient location, e.g. along with WinSCP.)). See example batch file: Once you find out what was the result of the script, you can perform any action you like. E.g. after evaluating exit code of WinSCP, you can send a "success" or "error" email. For that use any command-line email client you like, e.g. [[http://glob.com.au/sendmail/|sendmail]]((When installing sendmail, you can ignore all references to ''/usr/lib/'' (or ''c:\usr\lib'') directories in its installation instructions, as you will be running ''sendmail.exe'' directly from a Windows batch file. Just place sendmail files to any convenient location, e.g. along with WinSCP.)). See example batch file:
-<code>+<code batch>
winscp.com /script=example.txt winscp.com /script=example.txt
if errorlevel 1 goto error if errorlevel 1 goto error

Last modified: by martin