Forum Discussion
HKosova
Alumni
14 years agoHi Vova,
Here you are:
Here you are:
function Test()
{
var strWinSCP = "C:\\Program Files\\WinSCP\\winscp.com";
var strLogFile = "C:\\Test\\winscplog.xml";
var oShell = Sys.OleObject("WScript.Shell");
var oExec = oShell.Exec("\"" + strWinSCP + "\" /log=" + strLogFile);
// Feed commands to WinSCP
oExec.StdIn.WriteLine("option batch on");
oExec.StdIn.WriteLine("option confirm off");
oExec.StdIn.WriteLine("open session_URL_or_stored_session");
oExec.StdIn.WriteLine("get MyFile.csv C:\\Test\\");
oExec.StdIn.WriteLine("exit");
// Wait until the WinSCP execution is completed
while (oExec.Status == 0) Delay(100);
if (oExec.ExitCode == 0)
{
Log.Message("File download completed successfully.");
}
else
{
Log.Error("WinSCP exited with error code " + oExec.ExitCode +
". See Additional Information for details.",
aqFile.ReadWholeTextFile(strLogFile, aqFile.ctUTF8));
}
}
srini_molleti
9 years agoNew Contributor
Hi Helen,
In my case first I need to connect to a server using WinSCP. How to provide server name, username and password as input to the connection. Then I need to copy a file to the server, wait for few seconds and get the created output file to the local.
Could you please help me in writing a JavaScript code to achieve this.
Thanks for your help.