Interop: Start Process as another User => access denied

deV.chdeV.ch Member Posts: 543
edited 2011-08-09 in NAV Three Tier
I use some code to start a process under another user, but i always get an "access denied" error message.

What am i doing wrong? Is this limitation of interop?
Process := Process.Process();
ProcessInfo := ProcessInfo.ProcessStartInfo(_Filename,_Arguments);

ProcessInfo.UseShellExecute := FALSE;
ProcessInfo.LoadUserProfile := TRUE;

ProcessInfo.Domain := 'Domain';
ProcessInfo.UserName := 'user';
SetSecureString('thepassword',PasswordString);
ProcessInfo.Password := PasswordString;

Process.StartInfo := ProcessInfo;
Process.Start();

and here the SetSecureString Method:
_SecureString := _SecureString.SecureString();
FOR i := 1 TO STRLEN(_String) DO BEGIN
  _SecureString.AppendChar(_String[i]);
END;
Sign In or Register to comment.