Not able to upload files using Windows service

Advertisement

kkmark
Joined:
Posts:
1
Location:
Texas

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

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum