当程序作为计划任务运行时,安全异常访问注册表 [英] security exception accessing registry when the program runs as scheduled task
问题描述
以下小行抛出一个System.Security.SecurityException:不允许请求的注册表访问:
the following small line throws a System.Security.SecurityException: Requested registry access is not allowed:
RegistryKey _key = HKLM.OpenSubKey("path\\to\\my settings", false);
现在有些人会问什么?关键是这个仅在登录时运行。如果程序按照计划任务和没有人登录,则抛出异常。
Now.. what's the point some would ask? The point is that this runs ONLY when I am logged on. The exception is thrown if the program runs as scheduled task and nobody is logged on.
- 运行的用户该任务是本地管理员
- 程序不从网络共享运行,它位于本地磁盘上
- 我甚至尝试设置代码访问安全性
- 用户有权作为批处理作业登录
- the user who runs that task is local administrator
- the program does not run from a network share, it is located on the local disk
- I even tried setting Code Access Security
- the user has the rights to log on as a batch job
我有XP SP3应用所有补丁。该程序是用C#.Net 2.0(测试3.5)编写的。
I have XP SP3 with all patches applied. The program is written in C# .Net 2.0 (tested 3.5 too)
有谁知道这里的意义?
Torsten
Does anyone know whats the point here? Torsten
编辑:请参阅 http:// gist.github.com/638576
推荐答案
似乎这是这个特定的计算机的问题。我在另一个工作站上进行了测试,即使没有管理员权限也可以工作。
It seems that this is a problem of this specific computer. I tested it on another workstation and it works even without administrator privileges.
我认为这个程序运行多年没有任何问题...无论如何,感谢所有!
I assumed this - the program did run for years without any problems... Anyway, thanks to all!
这篇关于当程序作为计划任务运行时,安全异常访问注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!