Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Ep3demic

Thanks, i thoguht i did. But apperently not, it works now :D
Ep3demic

Re: JScript Fails Windows Server 2003

martin 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

Re: JScript Fails Windows Server 2003

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

JScript Fails Windows Server 2003

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)

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