Topic "Error-handling example for Session object in VBScript?"

Author Message
Telex123
[View user's profile]

Joined: 2012-03-08
Posts: 1
I just used the new COM Library to connect to my router (Cisco/Linksys router with TomatoUSB firmware) and enable/disable its wireless radio. I needed to accomplish this without using a command-line interface and WinSCP's new COM Library did the trick. Thank you for this new and very powerful functionality.

Quote:

set sessionOptions = WScript.CreateObject("WinSCP.SessionOptions")
with sessionOptions
.Protocol = 1 ' SCP
.HostName = "192.168.X.X"
.UserName = "myusername"
.Password = "mypassword"
.SshHostKey = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
end with

set session = WScript.CreateObject("WinSCP.Session")
session.Open sessionOptions
session.ExecuteCommand("wl -i eth1 radio on")


VBScript does not offer try/catch so the existing error-handling examples for C#, VB.NET and JScript cannot be used for VBScript. I would appreciate it if you could provide an example of how to test for errors generated by the Session object when used in VBScript. For example, an error may arise after using its Open or ExecuteCommand methods.

I suspect SessionRemoteException is used but I'm not sure how.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
I do not know myself. Will investigate and prepare some example.
Meanwhile this link might help:
http://stackoverflow.com/questions/4999364/try-catch-end-try-in-vbscript
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Example for error handling with VBScript added:
http://winscp.net/eng/docs/library_com_wsh#vberror
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License