在计划任务中模拟 .NET 用户时出错

发布于 2024-07-11 21:37:52 字数 849 浏览 5 评论 0原文

我有一个在 Windows Server 2003 上运行的 .NET 控制台应用程序,作为计划任务。

这使用 Process 类来运行另一个小型控制台应用程序,但它使用 Process.StartInfo.Username 来模拟用户来运行它。

如果在管理员的计划任务中模拟的帐户,那么它可以正常工作,但如果不是,那么我会收到错误:

“应用程序无法正确初始化 (0xc0000142)”

我尝试为用户提供“作为批处理作业登录”和“本地登录”,但这似乎没有任何效果。 控制台应用程序确实以模拟用户身份启动,但随后失败。

查看进程监视器,失败之前的最后一个事件是:

Tool1.exe - 加载映像 - C:\WINDOWS\system32\kernel32.dll - 成功

我已经运行取决于该工具,它报告这是错误:

GetProcAddress(0x77E40000 [c:\windows\system32\KERNEL32.DLL], "FlsAlloc") 从地址 0x7900746D 处的“c:\windows\system32\MSCOREE.DLL”调用,并由线程 1 返回 0x77E6B49C。 由线程 1 退出“c:\stfinstall\stf\tools\tool1\TOOL1.EXE”(进程 0xB3C),代码为 1282 (0x502)。

如果有人知道可能导致此错误的原因,或者更好,我该如何修复它,请告诉我!

也欢迎提出替代方法的建议,

谢谢:)

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 :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唔猫 2024-07-18 21:37:52

我已经解决了这个问题,问题是它无法访问计划任务运行的用户的桌面,所以它失败了。
管理员似乎能够拥有此访问权限。

我解决这个问题的方法是让任务运行的用户永久登录到盒子上,因此始终可以访问桌面,而且效果很好。 丑我知道!

I have since resolved this, the problem is that it doesnt have access to the desktop of the user the scheduled task runs as, so it fails.
Administrators seem to be able to have this access.

The way I got round it was to have the user the task runs as perpetually logged on to the box, so access to the desktop is always available, and this works OK. Ugly I know!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文