简体   繁体   English

启动进程时出现错误C0000142

[英]Error C0000142 when Starting a Process

I am trying to start a process under a different account (setting StartInfo.UserName/Password). 我正在尝试使用其他帐户(设置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. 当以交互方式运行但可以通过任务计划程序启动的进程运行它时,失败并显示错误-1073741502(C0000142;“ DLL初始化失败”),该方法有效。

I've tried to switch to the WIN32 API and to create a new WindowStation with STARTUPINFO.lpDesktop="" but I get the same error. 我试图切换到WIN32 API并使用STARTUPINFO.lpDesktop =“”创建一个新的WindowStation,但是遇到了同样的错误。

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? 更新 :我刚刚找到一个相关的问题,不幸的是,它也缺少答案:以.NET服务身份以其他用户身份启动.NET应用程序时的权限问题?

I was able to get it working using CreateProcessAsUser from here and adding LoadUserProfile from here . 我能得到它的工作使用来自CreateProcessAsUser 这里 ,并从增加LoadUserProfile 这里

Without LoadUserProfile a lot of tools will not work and give you strange errors because they need a home directory (eg svn.exe and mstest.exe). 没有LoadUserProfile,许多工具将无法工作,并给您带来奇怪的错误,因为它们需要主目录(例如svn.exe和mstest.exe)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM