windows 尝试使用任务计划程序 (Win7) 注册任务时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7770497/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error when trying to register a task with task scheduler (Win7)
提问by Robert
To enable my application to startup with admin rights at user login, I use a task in task scheduler. And it works fine. Mostly. Now I've received bug reports saying that this fails:
为了使我的应用程序能够在用户登录时以管理员权限启动,我在任务调度程序中使用了一个任务。它工作正常。大多。现在我收到错误报告说这失败了:
rootFolder->RegisterTaskDefinition( _bstr_t(name.toWideCharPointer()), task,
TASK_CREATE_OR_UPDATE, _variant_t(L"Builtin\Administrators"), _variant_t(),
TASK_LOGON_GROUP, _variant_t(L""), ®isteredTask) -> 0x80070534
0x80070534 seems to mean "No mapping between account names and security IDs was done". I'm following (pretty much verbatim) the example at: http://msdn.microsoft.com/en-us/library/aa381911(v=VS.85).aspx
0x80070534 似乎意味着“未完成帐户名称和安全 ID 之间的映射”。我正在关注(几乎是逐字逐句)示例:http: //msdn.microsoft.com/en-us/library/aa381911(v=VS.85) .aspx
Ideas what has gone wrong, and how to fix it ? The application has manifest set so the user needs to be admin to run it.
想法出了什么问题,以及如何解决?该应用程序已设置清单,因此用户需要成为管理员才能运行它。
Question: The "Builtin\\Administrators" group, it is language dependent, isn't it ? I think that the user in question might have a non-english Windows 7. If so I imagine it would work better with specifying "S-1-5-32-544" instead ( http://support.microsoft.com/kb/243330)
问题:“Builtin\\Administrators”组,它依赖于语言,不是吗?我认为有问题的用户可能有非英语的 Windows 7。如果是这样,我想它会更好地指定“S-1-5-32-544”(http://support.microsoft.com/kb /243330)
Update: So the explicit call looks like:
更新:所以显式调用看起来像:
rootFolder->RegisterTaskDefinition(
_bstr_t(name.toWideCharPointer()),
task,
TASK_CREATE_OR_UPDATE,
_variant_t(L"S-1-5-32-544"), // Language independent "BUILTIN\Administrators"
_variant_t(),
TASK_LOGON_GROUP,
_variant_t(L""),
®isteredTask)
Make sure that the application is executed with elevated privileges, otherwise that call will fail.
确保以提升的权限执行应用程序,否则该调用将失败。
采纳答案by Basj
After spending some time, I've seen that more modifications than just _variant_t(L"S-1-5-32-544")
are needed to make this "Logon Trigger Example (C++)" examplework.
花了一些时间后,我发现_variant_t(L"S-1-5-32-544")
需要进行更多的修改才能使这个“登录触发器示例 (C++)”示例工作。
All the details can be found in this answer.
所有细节都可以在这个答案中找到。
回答by Robert
The problem indeed lies in the parameter _variant_t(L"Builtin\\Administrators")
, which is hard-coded to English version of Windows. By using the language agnostic security identifier "S-1-5-32-544" ( http://support.microsoft.com/kb/243330), the problem is resolved.
问题确实在于参数_variant_t(L"Builtin\\Administrators")
,该参数硬编码为英文版Windows。通过使用与语言无关的安全标识符“S-1-5-32-544”(http://support.microsoft.com/kb/243330),问题得以解决。
Update: So the explicit call looks like:
更新:所以显式调用看起来像:
rootFolder->RegisterTaskDefinition(
_bstr_t(name.toWideCharPointer()),
task,
TASK_CREATE_OR_UPDATE,
_variant_t(L"S-1-5-32-544"), // Language independent "BUILTIN\Administrators"
_variant_t(),
TASK_LOGON_GROUP,
_variant_t(L""),
®isteredTask)
Make sure that the application is executed with elevated privileges, otherwise the call will fail.
确保以提升的权限执行应用程序,否则调用将失败。