Session.Dispose leaves sftp-server.exe ghost behind

Advertisement

MarcSimard
Joined:
Posts:
1
Location:
Canada

Session.Dispose leaves sftp-server.exe ghost behind

I noticed that I could not manually remove a file just uploaded to a SFTP site by my PowerShell script using Session.PutFiles. This is because the file was locked by a sftp-server.exe process (started by New-WinSCPSession) hanging in the background, even though I could confirm that Session.Dispose was called once the file was uploaded.

Is there a way to properly terminate the sftp-server.exe process once the SFTP operations are completed?

I am using WinSCP-5.17.9-Automation and the WinSCP Powershell module 5.17.8.1.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Session.Dispose leaves sftp-server.exe ghost behind

Do you have the problem with WinSCP GUI? Please post session log file both from the code and the GUI. Show us your code for WinSCP .NET assembly (WinSCP PowerShell module is a 3rd party project).

Reply with quote

marcsimard@...
Guest

Problem fixed

The problem has been completely addressed by making the following change in the PowerShell code:
Replace
$winscpSession.Dispose     # Close and dispose object. 
 
by
$winscpSession.Dispose()   # Close and dispose object. Note the pair of parentheses 
                           # added at the end of the method name.

Reply with quote

Advertisement

You can post new topics in this forum