Batch file -> Script file (AWS) WinSCP window immediately closes
I have a batch file to connect to an AWS SFTP server. Download all the files in the root folder to my current directory
Here is my
When executing this line, the WinSCP window (CMD) in the batch file immediately closes. I don't even have LOG files for these since it wasn't even given the time to enter the SFTP server
Anyone can help? Each line of code runs smoothly in CMD. Only the problem is when executing the batch file.
out\SYOHINMT\<time executed>
and copy all the files to \ftp_recieve\
SET BATLOGFILE="%~dp0log\sftp_recieve.log" SET BATLOGTEMP="%~dp0log\sftp_recieve_tmp.log" SET yyyyMMdd=%date:/=% SET hhmmss=%time: =0% SET hhmmss=%hhmmss:~0,2%%hhmmss:~3,2%%hhmmss:~6,2% mkdir "%~dp0out\SYOHINMT\%yyyyMMdd%_%hhmmss%" cd "%~dp0out\SYOHINMT\%yyyyMMdd%_%hhmmss%" "C:\Users\81803\AppData\Local\Programs\WinSCP\WinSCP.exe" /console /script="C:\Users\81803\デスクトップ\rad\conf\sftp_recieve.conf" /ini=nul /log="C:\Users\81803\デスクトップ\rad\log\winscplog.log" >> %BATLOGFILE% 2>&1 for /f "delims=" %%a in (%BATLOGTEMP%) do ( echo %%a >> %BATLOGFILE% 2>&1 echo "%%a" | find "%200 COMPLETED.%" >NUL if not ERRORLEVEL 1 set /a COMPCOUNT=COMPCOUNT+1 ) copy .\* ..\..\..\ftp_recieve\ >> %BATLOGFILE% 2>&1 EXIT
sftp_recieve.conf
script:
option batch on open sftp://xxxx@xxxx.amazonaws.com:22 -privatekey="C:xx\xxx\keys\xxxx.ppk" -hostkey="ssh-rsa 2048 xxxxxxxxxxx" get -resume ./* close exit
"C:\Users\81803\AppData\Local\Programs\WinSCP\WinSCP.exe" /console /script="C:\Users\81803\デスクトップ\rad\conf\sftp_recieve.conf" /ini=nul /log="C:\Users\81803\デスクトップ\rad\log\winscplog.log" >> %BATLOGFILE% 2>&1