d*****l 发帖数: 8441 | 1 C#新手遇阻:
cuEnvKey = Registry.CurrentUser.OpenSubKey("Environment");
if (cuEnvKey != null && cuEnvKey.GetValue("PATH") == null)
cuEnvKey.SetValue("PATH", strPathToAdd, RegistryValueKind.ExpandString);
错误信息:
Unhandled Exception: System.UnauthorizedAccessException: Cannot write to the
registry key.
对于CurrentUser的环境设置,若无“PATH"值,想给其设某个值,但是却得到“无权限
”的错误。
如果说CurrentUser的程序不能更改“LocalMachine"的环境非常好理解,但是
难道作为CurrentUser运行的程序都不能改变CurrentUser环境下的PATH设置吗?
CurrentUser无Administrator权限。
哪位大牛指点一下,谢谢! | P***a 发帖数: 4213 | 2 你直接编辑一下hkcu试试,可能你的用户组策略里禁了编辑注册表
the
【在 d*****l 的大作中提到】 : C#新手遇阻: : cuEnvKey = Registry.CurrentUser.OpenSubKey("Environment"); : if (cuEnvKey != null && cuEnvKey.GetValue("PATH") == null) : cuEnvKey.SetValue("PATH", strPathToAdd, RegistryValueKind.ExpandString); : 错误信息: : Unhandled Exception: System.UnauthorizedAccessException: Cannot write to the : registry key. : 对于CurrentUser的环境设置,若无“PATH"值,想给其设某个值,但是却得到“无权限 : ”的错误。 : 如果说CurrentUser的程序不能更改“LocalMachine"的环境非常好理解,但是
| d*****l 发帖数: 8441 | 3 直接用regedit修改是可以的。
【在 P***a 的大作中提到】 : 你直接编辑一下hkcu试试,可能你的用户组策略里禁了编辑注册表 : : the
|
|