如何更改注册表字符串值? [英] How to change Registry string value?

查看:275
本文介绍了如何更改注册表字符串值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有点困惑,试图弄清楚为什么类型字符串的注册表值不会随着我使用的代码而改变



Hello I am a bit confused trying to figure out why the registry value of type string does not change with the code that i am using

Dim myReg As RegistryKey = Registry.LocalMachine
           Dim MyRegKey As RegistryKey
           Dim MyVal As String
           MyRegKey = myReg.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", True)
           MyVal = MyRegKey.GetValue("Shell")
               MyRegKey.SetValue("Shell", "%windir%\explorer.exe, explorer.exe", RegistryValueKind.String)







任何帮助都会很棒谢谢!!



此代码不会抛出任何错误,它需要管理员权限,但regedit中的值似乎不会改变?




any help would be great thank you!!

This code throws no error and it requires admin privileges but the value will not seem to change in regedit?

推荐答案

您必须以管理员身份运行程序才能访问注册表。
You have to run the program as an administrator to access registry.


本文介绍如何将进程提升为以管理员身份运行。 http://code.msdn.microsoft.com/windowsdesktop/CSUACSelfElevation-644673d3 [ ^ ]



本文讨论在执行需要以管理员身份执行的代码块之前的模拟。



http: //stackoverflow.com/questions/1168571/run-code-as-a-different-user-c [ ^ ]
This article describes how to elevate a process to run as admin. http://code.msdn.microsoft.com/windowsdesktop/CSUACSelfElevation-644673d3[^]

This article talk about impersonation before executing a code block that needs to be executed as admin.

http://stackoverflow.com/questions/1168571/run-code-as-a-different-user-c[^]


这篇关于如何更改注册表字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆