Topic "JScript Fails Windows Server 2003"

Author Message
Ep3demic
[View user's profile]

Joined: 2013-04-10
Posts: 4
Hi,

I have had some problems setting up the envoriment on one of our servers running Windows Server 2003.
I have been following the guidelines on these sites (https://winscp.net/eng/docs/library_install)

Code:

<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>



It fails with this error message: Could not locate automation class named "WinSCP.SessionOptions".

Running from CMD with cscript test.wsf

WinSCP Is installed under C:\Apps\WinSCP, i have the .NET Assembly dll WinSCPnet.dll placed under the same folder.
The script is running from C:\Scripts. I have .Net Framework 3.5 Installed on the server

Other sample scripts are failing with the "WshShell.exec" object as source. I can run simple javascript code, but when i include your .NET Assembly to the code it fails.

What am i missing here?
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Ep3demic wrote:
Other sample scripts are failing with the "WshShell.exec" object as source.

Can you provide more details on this? What scripts? What error?
_________________
Martin Prikryl
Ep3demic
[View user's profile]

Joined: 2013-04-10
Posts: 4
prikryl wrote:
Ep3demic wrote:
Other sample scripts are failing with the "WshShell.exec" object as source.

Can you provide more details on this? What scripts? What error?


When i try to run the above code i get this error message:
<invalid link removed>

When i try to run the above code embedded in swf i get this error message:
---------------------------
Windows Script Host
---------------------------
Error: Could not locate automation class named "WinSCP.SessionOptions".
---------------------------
OK
---------------------------
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Did you register WinSCPnet.dll for COM?
https://winscp.net/eng/docs/library_install#registering
_________________
Martin Prikryl
Ep3demic
[View user's profile]

Joined: 2013-04-10
Posts: 4
Thanks, i thoguht i did. But apperently not, it works now Very Happy
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