Topic " returns exit code -1073741819 when automation runs under impersonated user"

Author Message
[View user's profile]

Joined: 2015-11-27
Posts: 3
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 {
[View user's profile]

Joined: 2015-11-27
Posts: 3
I guess below issue is related to my issue
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
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:

You can post new topics in this forum


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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License