I have a .NET console app running on Windows Server 2003, as a scheduled task.
This uses the Process class to run another little console app, but it uses Process.StartInfo.Username to impersonate a user to run it as.
If the account that is impersonated in the scheduled task in an Administrator, then it works perfectly, but if not then I get the error:
‘The application failed to initialize properly (0xc0000142)’
I have tried giving the user 'log on as a batch job' and 'log on locally' but this doesn't seem to have any effect. The console app does start up as the impersonated user, but then fails.
Looking at Process Monitor, the last event before it fails is:
Tool1.exe - Load Image - C:\WINDOWS\system32\kernel32.dll - SUCCESS
I have run Depends on the tool and it reports that this is the error:
GetProcAddress(0x77E40000 [c:\windows\system32\KERNEL32.DLL], "FlsAlloc") called from "c:\windows\system32\MSCOREE.DLL" at address 0x7900746D and returned 0x77E6B49C by thread 1. Exited "c:\stfinstall\stf\tools\tool1\TOOL1.EXE" (process 0xB3C) with code 1282 (0x502) by thread 1.
If anyone knows anything about what may be causing this error, or even better, how I can fix it, please let me know!
Suggestions of an alternative approach are also welcome
Thanks :)