Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Guest

Ok thanks, I'll retry

In fact I'm not using Windows Script File, so I don't know how to specify the <reference object="WinSCP.Session" />
My VB script is directly launch from a SCADA system. I have to ask the hotline.

But, for the moment I succeeded in running a command line:
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Dim cmd
cmd = """C:\Program Files (x86)\WinSCP\WinSCP.com"" /command ""open sftp://xxxxxxx/ -hostkey=""""ssh-ed25519 255 xxxxxxxxx="""""" ""lcd " & vtFolderName & " "" ""cd /data"" ""put " & vFileName & " "" ""exit"" "
' "0" pour que la fenêtre ne s'ouvre pas.
' "TRUE" pour attendre avant de passer à la ligne suivante.
Dim retv
retv = WshShell.Run(cmd, 0, True)
OlivierC

Error : Error skipping startup message. Your shell is probably incompatible with the application

Hello, I'm trying to run WinSCP from a VBS script, but I have the following error when I open the session:
Connection has been unexpectedly closed. Server sent command exit status 1.
Error skipping startup message. Your shell is probably incompatible with the application (BASH is recommended).

Note: the enum are not recognized, so I replace it the the corresponding value, found in the source code:
' Setup session options
Dim sessionOptions
Set sessionOptions = CreateObject("WinSCP.SessionOptions")
With sessionOptions
    .Protocol = 1 'Protocol_Sftp
    .HostName = "toto.com"
    .UserName = "toto"
    .Password = "abvc"
    .SshHostKeyFingerprint = "sshxxxxxx"
End With
 
Dim session
Set session = CreateObject("WinSCP.Session")
 
' Connect
session.Open sessionOptions
' >> ERROR !   
' Upload files
Dim transferOptions
Set transferOptions = CreateObject("WinSCP.TransferOptions")
transferOptions.TransferMode = 0 'TransferMode_Binary
 
Dim transferResult
Set transferResult = session.PutFiles(vtFolderName & vFileName, "/data/", False, transferOptions)