Thanks, I thought I did. But apparently not, it works now :D
- Ep3demic
---------------------------
Windows Script Host
---------------------------
Error: Could not locate automation class named "WinSCP.SessionOptions".
---------------------------
OK
---------------------------
Other sample scripts are failing with theWshShell.execobject as source.
<job>
<reference object="WinSCP.Session" />
<script language="JScript">
try
{
// Setup session options
var sessionOptions = WScript.CreateObject("WinSCP.SessionOptions");
sessionOptions.Protocol = Protocol_Sftp;
sessionOptions.HostName = "example.com";
sessionOptions.UserName = "user";
sessionOptions.Password = "mypassword";
sessionOptions.SshHostKeyFingerprint = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx";
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("d:\\toupload\\*", "/home/user/", 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);
}
</script>
</job>
Could not locate automation class named "WinSCP.SessionOptions".
cscript test.wsfC:\Apps\WinSCP. I have the .NET Assembly dll WinSCPnet.dll placed under the same folder.
C:\Scripts. I have .NET Framework 3.5 Installed on the server.
WshShell.exec object as source. I can run simple JavaScript code, but when i include your .NET Assembly to the code it fails.