WinSCP.Session
Hi I'm new to scripting with WinSCP.
I used the following script (script starts after error message) to connect to our FTP server. I removed the sessionOptions values for security reasons. But when I run the script I get the following message:
---------------------------
Windows Script Host
---------------------------
Script: C:\Users\asulbaran\Documents\WinSCPCISS.wsf
Line: 3
Char: 21
Error: Cannot find the type library for this reference : WinSCP.Session
Code: 80040068
Source: Windows Script Host
---------------------------
OK
---------------------------
<job>
<reference object="WinSCP.Session" />
<script language="JScript">
try
{
// Setup session options
var sessionOptions = WScript.CreateObject("WinSCP.SessionOptions");
sessionOptions.Protocol = Protocol_Sftp;
sessionOptions.HostName = "";
sessionOptions.UserName = "";
sessionOptions.Password = "";
sessionOptions.SshHostKeyFingerprint = "";
var session = WScript.CreateObject("WinSCP.Session");
try
{
// Connect
session.Open(sessionOptions);
// Upload files
var transferOptions = WScript.CreateObject("WinSCP.TransferOptions");
transferOptions.TransferMode = TransferMode_Binary;
var transferResult = session.PutFiles("C:\\Users\\asulbaran\Documents\\desktop.ini", "/BBRB", false, transferOptions);
// Throw on any error
transferResult.Check();
// Print results
for (var enumerator = new Enumerator(transferResult.Transfers); !enumerator.atEnd(); enumerator.moveNext())
{
WScript.Echo("Upload of " + enumerator.item().FileName + " succeeded");
}
}
finally
{
// Disconnect, clean up
session.Dispose();
}
}
catch (e)
{
WScript.Echo("Error: " + e.message);
WScript.Quit(1);
}
I used the following script (script starts after error message) to connect to our FTP server. I removed the sessionOptions values for security reasons. But when I run the script I get the following message:
---------------------------
Windows Script Host
---------------------------
Script: C:\Users\asulbaran\Documents\WinSCPCISS.wsf
Line: 3
Char: 21
Error: Cannot find the type library for this reference : WinSCP.Session
Code: 80040068
Source: Windows Script Host
---------------------------
OK
---------------------------
<job>
<reference object="WinSCP.Session" />
<script language="JScript">
try
{
// Setup session options
var sessionOptions = WScript.CreateObject("WinSCP.SessionOptions");
sessionOptions.Protocol = Protocol_Sftp;
sessionOptions.HostName = "";
sessionOptions.UserName = "";
sessionOptions.Password = "";
sessionOptions.SshHostKeyFingerprint = "";
var session = WScript.CreateObject("WinSCP.Session");
try
{
// Connect
session.Open(sessionOptions);
// Upload files
var transferOptions = WScript.CreateObject("WinSCP.TransferOptions");
transferOptions.TransferMode = TransferMode_Binary;
var transferResult = session.PutFiles("C:\\Users\\asulbaran\Documents\\desktop.ini", "/BBRB", false, transferOptions);
// Throw on any error
transferResult.Check();
// Print results
for (var enumerator = new Enumerator(transferResult.Transfers); !enumerator.atEnd(); enumerator.moveNext())
{
WScript.Echo("Upload of " + enumerator.item().FileName + " succeeded");
}
}
finally
{
// Disconnect, clean up
session.Dispose();
}
}
catch (e)
{
WScript.Echo("Error: " + e.message);
WScript.Quit(1);
}