Topic "Not able to upload files using Windows service"

Author Message
kkmark
[View user's profile]

Joined: 2009-12-01
Posts: 1
Location: Texas
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="http://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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Please read FAQ. If that does not help, come back.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License