Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: returns exit code -1073741819 when automation runs under impersonated user

Thanks for your report.

I have sent you an email with a development version of WinSCP to the address you have used to register on this forum.

This issue is tracked here:
rrasal returns exit code -1073741819 when automation runs under impersonated user

Trying to SFTP from website (running under IIS).
When try to run code through user impersonation, process is not starting.
It returns exit code "-1073741819" but doesn't return any error text or output.
Impersonated user is Administrator on the machine, so ideally user should have full access right.
If we execute same commands manually by logging onto server with same user everything works fine.

If we remove impersonation then automation part also works perfectly fine.
This time it runs under <machine_name>$ user.

To me it looks like something has to do with impersonation.

**Note: Recently we migrated from Windows Server 2008 to 2012
Same code was working fine with 2008 and WinSCP version 4.3.7 (build 1679)

WinSCP Version 5.7.6 (Build 5874) (OS 6.3.9600 - Windows Server 2012 R2 Standard)
Transfer Protocol : SFTP
Mode : Automation using impersanation

Process _proc = new Process();

_proc.StartInfo.UseShellExecute = false;
_proc.StartInfo.CreateNoWindow = true;
_proc.StartInfo.FileName = "C:\Program Files (x86)\WinSCP\";
_proc.StartInfo.RedirectStandardInput = true;
_proc.StartInfo.RedirectStandardError = true;
_proc.StartInfo.RedirectStandardOutput = true;
_proc.StartInfo.Arguments = "/log='<log file path>'"

_proc.StandardInput.WriteLine("option batch on");
_proc.StandardInput.WriteLine("option transfer binary");
_proc.StandardInput.WriteLine("option batch abort");
_proc.StandardInput.WriteLine("option confirm off");
_proc.StandardInput.WriteLine("open sftp://<USER_NAME>:<PASSWORD>@<SERVER_IP>:22 -timeout=120 -hostkey='ssh-rsa 1024 xx:ax:aa:aa:ax:aa:ax:xx:xx:xx:ax:xa:xx:xx:ax:aa'");
_proc.StandardInput.WriteLine("Get '<source file path>' '<target file path>'");

StreamReader _errorStream = _proc.StandardError;
StreamReader _outputStream = _proc.StandardOutput;


string _stdError = _errorStream.ReadToEnd();
string _stdOutput = _outputStream.ReadToEnd();

int _exitCode = _proc.ExitCode;
} catch (Exception ex) {
} finally {