Topic "WinSCP hangs with ASP.NET"

Author Message
brees
[View user's profile]

Joined: 2007-03-07
Posts: 4
winscp connects and transfers the files with no problems.
when I run my batch file from the command line, winscp runs/exits as it should
when I run my batch file within asp.net, it connects and transfers without any problems but it the process does not terminate unless I go into task manager.

i have read to faq as well as the documentation, so I please don't offer that as a solution.

It should not the settings in the registry because I'm using the ini file.

here is all my code:

--------------
winscp.bat
--------------
@echo off

call "c:\program files\winscp3\winscp3.com" /script="%1"

exit

--------------------
script.txt
//dynamically generated, file name changes with each order
//ex: order_[datetime].dat.txt
--------------------
option batch on
option confirm off

open [user name]:[password]@[sftp server]:[port]
option transfer binary

cd "/home/incoming"
put "C:\orders\outgoing\order_20070307145630.dat" //matching order file
close
exit

---------------------
asp.net (c#) code
---------------------
string orderTime = DateTime.Now.ToString("yyyyMMddHHmm");
string filePath = string.Format(@"c:\orders\outgoing\order_{0}.dat",orderTime);
string scriptPath = string.Format(@"c:\orders\scripts\order_{0}.dat.txt",orderTime);

//GenerateFtpFile(filePath);
//GenerateFtpScript(scriptPath);

ProcessStartInfo si = new ProcessStartInfo();
si.FileName = @"c:\orders\winscp.bat";
si.Arguments = scriptPath;
si.CreateNoWindow = true;
si.UseShellExecute = false;

int maxTime = 100000;
int executeTime = 0;
Process executeBatchProcess = Process.Start(si);
do
{
executeTime += 1000;
executeBatchProcess.Refresh();

if (executeTime > maxTime)
{
executeBatchProcess.Kill();
break;
}
}
while (!executeBatchProcess.WaitForExit(1000));
executeBatchProcess.CloseMainWindow();
executeBatchProcess.Close();

-----------------------------------

that's it, nothing extremely difficult or fancy.
winscp never exits, the command console will close only if I call "executeBatchProcess.Kill();" but winscp still runs.

the only way to stop winscp is to go into the task manager.

I have seen other post on this forum, but still no solutions, such as topic: 2309

what do i need to do to fix this issue?
Advertisements
brees
[View user's profile]

Joined: 2007-03-07
Posts: 4
It appears that the asp.net worker process needs to have write access to the ini file. If it does not have write access, then it obviously causes an error and the script does not exit as it should.

It would be nice if the documentation or the FAQ, that is so highly regarded by the administrator would note such a requirement.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Thanks for hint.
_________________
Martin Prikryl
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
See guide to using WinSCP from .NET.
_________________
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