Click here to Skip to main content
14,298,783 members
Rate this:
Please Sign up or sign in to vote.
See more:
I need to transfer multiple files from a remote server to local machine.

I have then scheduled winscp.exe with argument "/console/script=D:\sync.txt"
sync.txt file contains the following commands.

option batch on
option confirm off
open username@hostname
cd folderContainingFiles
option transfer binary
get /desiredFile.extension pathInLocalComputer
exit

When I am running the task, winscp window is opening but it is not logging in.

Any help anyone?

What I have tried:

option batch on
option confirm off
open username@hostname
cd folderContainingFiles
option transfer binary
get /desiredFile.extension pathInLocalComputer
exit
Posted
Updated 9-Jun-16 1:36am
v3
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hey,

I did by creating batch file on the run and then opening cmd application and then running it.

Here is my code if it helps anyone:

//creating batch file
            StreamWriter sw = new StreamWriter(@"C:\\file_transfer.bat");
 
            sw.WriteLine("open username:password@host");
            sw.WriteLine("option transfer binary");
            sw.WriteLine("cd /mainFolder/subFolder");
            sw.WriteLine("get file.extension C:\\pathWhereYouWantToPutIt\\");
            sw.WriteLine("get *.extension C:\\pathWhereYouWantToPutIt\\");
//second get for multiple files
            sw.WriteLine("exit");
            sw.Close();



//file transfer
            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.WorkingDirectory = @"C:\\Windows\\System32";
            p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.Start();

            p.StandardInput.WriteLine(@"cd C:\\If-You-Want-To-Go-To-Another-Directory");
            p.StandardInput.WriteLine("WinSCP.com /script=\"C:\\file_transfer.bat");
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100