martin wrote:
What is command-line you use to run WinSCP? What is startup directory of the command? What is a path to the log
folder?
Thanks for your quick reply.
Actually I prepared console application,if I run manually script is working fine. when i automate using windows task scheduler the problem is happening.
I have placed my .exe in following location in a server. C:\FTP_Automation\HRIQ_OTS_FTP. The logs will generate in following location. C:\FTP_Automation\HRIQ_OTS_FTP\logs\.
I have given full access permission as well as I added Network Service account to the "HRIQ_OTS_FTP" folder.
Below is my sample winscp code.
winscp = new Process();
winscp.StartInfo.FileName = ClientPath;
winscp.StartInfo.Arguments = "/log=" + ClientLog;
winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.RedirectStandardOutput = true;
winscp.StartInfo.CreateNoWindow = true;
winscp.Start();
winscp.StandardInput.WriteLine("option batch abort");
winscp.StandardInput.WriteLine("option confirm off");
winscp.StandardInput.WriteLine(string.Format("open sftp://{0}@{1}:{2} -privatekey=\"{3}\"", HostUser, HostIP, HostPort, PrivateKey));
winscp.StandardInput.WriteLine(string.Format("StartInfo Argument {0}", winscp.StartInfo.Arguments.ToString()));
winscp.StandardInput.WriteLine(string.Format("cd {0}", HostRoot));
winscp.StandardInput.WriteLine(string.Format("lcd {0}", ClientRoot));
winscp.StandardInput.WriteLine("option transfer binary");
out put:
winscp> option confirm off
confirm off
winscp> open sftp://hriqftp@210.56.134.96:22 -privatekey="C:\FTP_Automation\HRIQFTPKeys\privatekey.ppk"
141
Can't open log file '.\log\scpLog.xml'.
Searching for host...
Connecting to host...
Authenticating...
Using username "hriqftp".
Authenticating with public key "rsa-key-201xxx22".
Authenticated.