2

My .Net-Windows-Forms-Application is running impersonated as another user. The program starts another .net-exe which instantiates from an interop-assembly. The external program crashes when trying to instantiate from the interop assembly. If I start the external exe per Shift-RightClick-RunAsOtherUser and put in the same login-data as for impersonation, the program works fine.

Perhaps it has sth. to do with my process start call:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName         = Path.Combine(System.Windows.Forms.Application.StartupPath, exeFile);
startInfo.Arguments        = arguments;
Process process            = Process.Start(startInfo);
process.WaitForExit();

[EDIT]

Crash Details: On a vmWare and my dev machine: No exception-window, nothing, external application is executed and then disappears (I put some messageboxes in it to check).

On customers machine: Exception Window

Unknown error (0xffff...e)
Win32Exception
System
StartWithShellExecuteEx
  at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
riQQ
  • 9,878
  • 7
  • 49
  • 66
Inno
  • 2,567
  • 5
  • 32
  • 44

1 Answers1

0

If you know the Username and Password you can set those properties in the startup info for the process. If only have an impersonation token I think your stuck using pinvoke of CreateProcessAsUser ttp://msdn.microsoft.com/en-us/library/windows/desktop/ms682429%28v=vs.85%29.aspx

Process.Start overload with username, password and domain: http://msdn.microsoft.com/en-us/library/sxf2saat.aspx

PInvoke CreateProcessAsUser has a SO question and answer already: https://stackoverflow.com/a/671368/884862

Community
  • 1
  • 1
Louis Ricci
  • 20,804
  • 5
  • 48
  • 62
  • Process.Start overload with username, password and domain throws an "Access Denied" exception. – Inno Jan 30 '13 at 15:03