Differences
This shows you the differences between the selected revisions of the page.
| library_com_wsh 2017-10-09 | library_com_wsh 2022-10-21 (current) | ||
| Line 26: | Line 26: | ||
| sessionOptions.UserName = "user"; | sessionOptions.UserName = "user"; | ||
| sessionOptions.Password = "mypassword"; | sessionOptions.Password = "mypassword"; | ||
| - | sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..."; | + | sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..."; | 
| var session = WScript.CreateObject("WinSCP.Session"); | var session = WScript.CreateObject("WinSCP.Session"); | ||
| Line 43: | Line 43: | ||
| </code> | </code> | ||
| - | ==== Event Handlers ==== | + | ==== [[event_handlers]] Event Handlers ==== | 
| The ''[[library_session|Session]]'' class exposes several [[library_session#events|events]]. | The ''[[library_session|Session]]'' class exposes several [[library_session#events|events]]. | ||
| Line 77: | Line 77: | ||
| VBScript does not support catching exceptions, what is a common way of handling errors in examples for most other languages. | VBScript does not support catching exceptions, what is a common way of handling errors in examples for most other languages. | ||
| - | In case you need to use custom error handling, instead of aborting the script on error (the default for WSH), use ''[[msdn>53f3k80h|On Error]]'' statement. | + | In case you need to use custom error handling, instead of aborting the script on error (the default for WSH), use ''[[https://learn.microsoft.com/en-us/previous-versions/53f3k80h(v=vs.85)|On Error]]'' statement. | 
| - | Use ''On Error Resume Next'' to disable default error handling. Then you need to query ''[[msdn>sbf5ze0e|Err.Number]]'' after every statement to test for errors. You can revert to default error handling (aborting the script) using ''On Error GoTo 0''. | + | Use ''On Error Resume Next'' to disable default error handling. Then you need to query ''[[https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/err-object|Err.Number]]'' after every statement to test for errors. You can revert to default error handling (aborting the script) using ''On Error GoTo 0''. | 
| <code vb> | <code vb> | ||
| Line 171: | Line 171: | ||
| sessionOptions.UserName = "user"; | sessionOptions.UserName = "user"; | ||
| sessionOptions.Password = "mypassword"; | sessionOptions.Password = "mypassword"; | ||
| - | sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..."; | + | sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..."; | 
| var session = WScript.CreateObject("WinSCP.Session"); | var session = WScript.CreateObject("WinSCP.Session"); | ||
| Line 184: | Line 184: | ||
| transferOptions.TransferMode = TransferMode_Binary; | transferOptions.TransferMode = TransferMode_Binary; | ||
| - | var transferResult = session.PutFiles("d:\\toupload\\*", "/home/user/", false, transferOptions); | + | var transferResult = | 
| + | ···········session.PutFiles("d:\\toupload\\*", "/home/user/", false, transferOptions); | ||
| // Throw on any error | // Throw on any error | ||
| Line 190: | Line 191: | ||
| // Print results | // Print results | ||
| - | for (var enumerator = new Enumerator(transferResult.Transfers); !enumerator.atEnd(); enumerator.moveNext()) | + | var enumerator = new Enumerator(transferResult.Transfers); | 
| + | for (; !enumerator.atEnd(); enumerator.moveNext()) | ||
| { | { | ||
| WScript.Echo("Upload of " + enumerator.item().FileName + " succeeded"); | WScript.Echo("Upload of " + enumerator.item().FileName + " succeeded"); | ||
| Line 231: | Line 233: | ||
| .UserName = "user" | .UserName = "user" | ||
| .Password = "mypassword" | .Password = "mypassword" | ||
| - | .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." | + | .SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..." | 
| End With | End With | ||