Hi, I am having trouble to connect to remote ftps server with .wsf scripts. But I can connect with WinSCP program and WS_FTP program. The error message is "connection failed" and the error code is 80131500. Here is code I am using:
<job>                                                               
<reference object="WinSCP.Session"/>
<script language="VBScript">
 
Option Explicit
 
' Setup session options
Dim sessionOptions
Set sessionOptions = WScript.CreateObject("WinSCP.SessionOptions")
With sessionOptions
    .Protocol = Protocol_ftp
    .ftpSecure = FtpSecure_Implicit
    .PortNumber = 62000
    .HostName = "xxxxx.xx.xxx"
    .UserName = "xxxxxx"
    .Password = "xxxxxxx"
   
End With
 
Dim session 
Set session = WScript.CreateObject("WinSCP.Session")
 
' Connect
session.Open sessionOptions
 
Dim today, stamp, logdate
logdate = Now & VbCrLf
today = Date
stamp = Year(today)
If Month(today) < 10 Then
    stamp = stamp & "0"
End If
stamp = stamp & Month(today)
if Day(today) - 1 < 10 Then
    stamp = stamp & "0"
End If
stamp = stamp & Day(today)
 
Dim fileName, remotePath, localPath
fileName = stamp & "_DATA.csv"
remotePath = "/xxx/xx_xxx_"  & fileName
localPath = "x:\xx\xxx\xxx\xxxxD_" & fileName
 
Dim fs, sftplog
Set fs = WScript.CreateObject("Scripting.FileSystemObject")
Set sftplog = fs.OpenTextFile("E:\xxx\xxx.log", 8, True)   '1 = reading, 2 = writing new, 8 = appending    
 
Dim download, remoteWriteTime, localWriteTime
 
If session.FileExists(remotePath) Then
    If Not fs.FileExists(localPath) Then
        sftplog.WriteLine logdate & " File " & remotePath & " exists, local backup " & localPath & " does not"
        download = True
    Else
        remoteWriteTime = CDate(session.GetFileInfo(remotePath).LastWriteTime)
        localWriteTime = fs.GetFile(localPath).DateLastModified
 
        If remoteWriteTime > localWriteTime Then
            sftplog.WriteLine _
                logdate & " File " & remotePath & " as well as local backup " & localPath & " exist, " & _
                "but remote file is newer (" & remoteWriteTime & ") than local backup (" & localWriteTime & ")"
            download = True
        Else
            sftplog.WriteLine _
                logdate & " File " & remotePath & " as well as local backup " & localPath & " already existed. " 
                sftplog.WriteLine " Remote file created on " & remoteWriteTime 
                sftplog.WriteLine " Local backup " & localWriteTime 
            download = False
        End If
    End If
 
    If download Then
        ' Download the file and throw on any error
        session.GetFiles(remotePath, localPath).Check()
 
        sftplog.WriteLine logdate & " Download to backup done."
    End If
Else
    sftplog.WriteLine logdate & " File " & remotePath & " does not exist yet"
End If
sftplog.Close 
' Disconnect, clean up
session.Dispose
 
</script>
</job>
Kindly help me to solve this problem.