ftp login problems when using .Net Assembly

Advertisement

GeertV
Joined:
Posts:
3
Location:
Antwerp

ftp login problems when using .Net Assembly

Hi,

I'm trying to use vbscript for logging in into an ftp server but that fails.

Set SessionOptions = WScript.CreateObject("WinSCP.SessionOptions")
Set Session = WScript.CreateObject("WinSCP.Session")

With SessionOptions
   .Protocol = Protocol_Ftp
   .HostName = "ftpserver"
   .UserName = "username"
   .Password = "password"
End With
session.Open sessionOptions
Error message: SessionOptions.Protocol is Protocol.sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set.
Code: 80070057

The following code for logging in into an sftp server works fine:
Set SessionOptions = WScript.CreateObject("WinSCP.SessionOptions")
Set Session = WScript.CreateObject("WinSCP.Session")

With SessionOptions
   .Protocol = Protocol_Sftp
   .HostName = "sftpserver"
   .UserName = "username"
   .Password = "password"
   '.SshHostKeyFingerprint = "ssh-rsa xxxxxxxx"
End With
session.Open sessionOptions
Problem is that I would like to access both ftp and sftp servers via the code.
Any idea's?

Using: version 5.15 build 9365

Thanks,
Geert

Reply with quote

Advertisement

GeertV
Joined:
Posts:
3
Location:
Antwerp

Re: ftp login problems when using .Net Assembly

martin wrote:


Hi Martin,

Yes, the WinScp assembly was registered via:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe C:\Windows\WinSCPnet.dll /codebase /tlb:WinSCPnet64.tlb
C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe C:\Windows\WinSCPnet.dll /codebase /tlb:WinSCPnet32.tlb

The library also shows up in the vbsedit object browser, what proves that the library was registered correctly.
Tried using both the 32 and 64 bit scripting engine and I'm always getting the same error.

Thanks for getting back to me

Reply with quote

martin
Site Admin
martin avatar

Re: ftp login problems when using .Net Assembly

My link specifically points to "Accessing Enumeration Values" section.

Reply with quote

GeertV
Joined:
Posts:
3
Location:
Antwerp

Re: ftp login problems when using .Net Assembly

martin wrote:

My link specifically points to "Accessing Enumeration Values" section.
Hi Martin,

ok. Got it working. Thanks for the tip but unfortunately there's no way to include those values in vbscript but I was able to work around it by looking up theose values using a wsf script:
<job>
<reference object="WinSCP.Session" />
<script language="vbScript">
 
Set SessionOptions = WScript.CreateObject("WinSCP.SessionOptions")

WScript.Echo Protocol_Sftp ' gives 0
WScript.Echo Protocol_Ftp ' gives 2

WScript.Echo SynchronizationMode_Local ' gives 0
WScript.Echo SynchronizationMode_Remote 'gives 1
WScript.Echo SynchronizationMode_Both 'gives2

</script>
</job>

Reply with quote

Advertisement

You can post new topics in this forum