Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

martin

Re: Not able to upload files using Windows service

Please read FAQ. If that does not help, come back.
kkmark

Not able to upload files using Windows service

Hi

i am trying to upload files from Local system to Remote system using SFTP

when i look into log file this is the information i see

<?xml version="1.0" encoding="UTF-8" ?>
<session xmlns="https://winscp.net/schema/session/1.0" name="user@abc.com" start="2009-11-30T22:20:20.296Z" />


When i run the script using regular button click method it works fine but when i use windows service and put it on my production server it creates files on my local folder but doesn't send files to remote system.

below is the script i am using
Const logname As String = "C:\log.xml"

' Run hidden WinSCP process
Dim winscp As Process = New Process()
winscp.StartInfo.FileName = "C:\program files\winscp\winscp.com"
winscp.StartInfo.Arguments = "/log=" + logname
winscp.StartInfo.UseShellExecute = False
winscp.StartInfo.RedirectStandardInput = True
winscp.StartInfo.RedirectStandardOutput = True
winscp.StartInfo.CreateNoWindow = True
winscp.Start()

' Feed in the scripting commands
winscp.StandardInput.WriteLine("option batch abort")
winscp.StandardInput.WriteLine("option confirm off")
winscp.StandardInput.WriteLine("option transfer binary")
winscp.StandardInput.WriteLine("open sftp://user:pass@abc.com")
winscp.StandardInput.WriteLine("cd /x/y/")
winscp.StandardInput.WriteLine("put" & path)
winscp.StandardInput.WriteLine("close")
winscp.StandardInput.WriteLine("exit")
winscp.StandardInput.Close()

' Collect all output (not used in this example)
Dim output As String = winscp.StandardOutput.ReadToEnd()

' Wait until WinSCP finishes
winscp.WaitForExit()
when i run it throught winscp.com it works fine

please help