Created an exe file that is scheduled with Windows Task Scheduler in Windows Server 2016. When scheduled, the applications executes correctly until the WINSCP connection, when the process logs a failure when the connection is opened:
3/29/2021 7:31:15 PM: WinSCP.SessionRemoteException: Connection failed.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
at WinSCP.SessionLogReader.Read(LogReadFlags flags)
at WinSCP.ElementLogReader.Read(LogReadFlags flags)
at WinSCP.SessionElementLogReader.Read(LogReadFlags flags)
at WinSCP.CustomLogReader.TryWaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.CustomLogReader.WaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.Session.Open(SessionOptions sessionOptions)
at ConsoleApplication1.Module1.Main() in C:\Projects\Module1.vb:line 192
If run interactively, the applications runs as expected, including opening the connection and uploading via WINSCP with no issues. Both the interactive user and the Scheduled Task user are local administrators on this server.