I am writing a VBScript (WSF file actually) to try to use ListDirectory to list out all of the files in the directory.
When I try to run the code below, I get an error "Object Required: WinSCP.RemoteDirecto" on the bolded line in the code, which I assume is RemoteDirectoryInfo. Is there a way I can get this to run in VBScript? I tried setting the directory variable to a CreatObject of WinSCP.RemoteDirectoryInfo, but that is not an automated class.
Can anyone point me in the right direction, or at least let me know that VBScript is not viable for ListDirectory? I tried the documentation on the WinSCP website, but they don't have a VBScript example for ListDirectory.
Any help would be appreciated.
' Setup session options
Set sessionOptions = WScript.CreateObject("WinSCP.SessionOptions")
.Protocol = Protocol_Sftp
.HostName = "<my Hostname>"
.UserName = "<my Username>
.Password = "<my Password>"
.PortNumber = 22
.SshHostKeyFingerprint = "<the SSH Key>"
Set session = WScript.CreateObject("WinSCP.Session")
directory = session.ListDirectory("/Inbox")
For Each fileInfo In directory.Files
' Disconnect, clean up