# Batch file script

bw5500@hotmail.com
Joined:
Posts:
4
Location:
Summit County, OH

## Batch file script

Trying to insert a get command into a batch file, however between the syntax and the help screens this WinSCP is like no other to figure out. Need to get from an SFTP and pull to a local. Generated the transfer code in the GUI but inserting the additional command is not working. please advise.

Guest

## batch file script

The script generator has "Your command 1" and "Your command 2" , but doesnt seem to work, so either im not using correct syntax for WinSCP, or I have the script in the wrong position. see below, please advise.

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\writable\path\to\log\WinSCP.log" /ini=nul ^
/command ^
"open sftp://abc@123.server.transfer.us-west-2.xyz.com/ -hostkey=""ssh-rsa 1234 abc123="" -privatekey=""\\server.abc.network\Data\FILE_SHARE\me\ABC.ppk""" ^
"GET abc.txt "F:\def\"" ^
"exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)

exit /b %WINSCP_RESULT%

bw5500@hotmail.com

## batch file script

Thank you, unfortunately both examples return same error, "The system cannot find the file specified". The file can be moved manually however the file is not found when written to a batch file. Please advise, as this is the WinSCP is the first software i have ever had issues with integrating to a batch file for a scheduled task. having to use the WinSCP due to sftp hostkey requirements.

martin
Joined:
Posts:
37,599
Location:
Prague, Czechia

## Re: batch file script

OK, you have another problem in your batch file. I believe it's quite obvious. You didn't replace the placeholder C:\writable\path\to\log\ with an actual path. So WinSCP tries to log to a folder that does not exist. Use a real path.

If this still does not help, please post your new complete script/batch file. A log file can be useful too.

Also make sure you have read complete article I've linked above. It deals with common problems people have when using WinSCP from a batch file:
https://winscp.net/eng/docs/faq_batch_file

You can post new topics in this forum