4

I am trying to start a process under a different account (setting StartInfo.UserName/Password).

This works when run interactive but fails with error -1073741502 (C0000142; "DLL Initialization Failed") when trying to run it from a process that was started via the Task Scheduler.

I've tried to switch to the WIN32 API and to create a new WindowStation with STARTUPINFO.lpDesktop="" but I get the same error.

Update: I just found a related question, unfortunately it is also missing an answer: Permissions problem when starting .NET app from .NET service as a different user?

Community
  • 1
  • 1
laktak
  • 57,064
  • 17
  • 134
  • 164

1 Answers1

2

I was able to get it working using CreateProcessAsUser from here and adding LoadUserProfile from here.

Without LoadUserProfile a lot of tools will not work and give you strange errors because they need a home directory (e.g. svn.exe and mstest.exe).

Community
  • 1
  • 1
laktak
  • 57,064
  • 17
  • 134
  • 164