Re: Scripting in Powershell
thanks worked like a charm !
regards
regards
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
winscp.exe
is a GUI application. PowerShell does not seem to wait for GUI application to exit before proceeding to the next comment. So the $LASTEXITCODE
cannot contain the exit code as the application has not exited yet. Use winscp.com
instead, what is a console application.
winscp.exe /console /script=test1.txt /log=ftp.log
ErrorLevel 0
winscp.exe /console /script=test2.txt /log=ftp.log
ErrorLevel 1
pause
Press any key to continue . . .
.\test1.ps1
0
0
.\winscp.exe /console /script=test1.txt /log=ftp.log
$LASTEXITCODE
.\winscp.exe /console /script=test2.txt /log=ftp.log
$LASTEXITCODE
. 2014-01-15 12:24:51.561 Script: Failed
. 2014-01-15 12:24:51.561 Script: Exit code: 1
. 2014-01-15 12:24:51.561 Disconnected from server
< 2014-01-15 12:24:51.567 226 Closing data connection