WinSCP hangs with ASP.NET

Advertisement

brees
Joined:
Posts:
4

WinSCP hangs with ASP.NET

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?

Reply with quote

Advertisement

brees
Joined:
Posts:
4

answer to my own question

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.

Reply with quote

Advertisement

You can post new topics in this forum