更改Shell注册表

时间:2012-12-02 07:26:21

标签: c# windows registry windows-shell regedit

在我的应用程序开始时,我将注册表的shell值更改为自定义shell并终止explorer.exe(它在应用程序外部完成),我想允许后门返回到原始shell并带来返回explorer.exe。恢复过程对我来说很好但是当我运行我的代码来更改注册表值时,没有抛出异常但是当我检入regedit时值不会改变, 这是我的代码(在不同的问题上看到它):

        RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
        regKey.SetValue("Shell", "explorer.exe", RegistryValueKind.String);
        regKey.Close();

请帮忙

1 个答案:

答案 0 :(得分:4)

在您的代码中,您实际上设置了

的值
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell

由于某些注册表项被WOW64重定向,请检查MSDN以获取更多详细信息。

试试这个:

RegistryKey localMachine = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);

RegistryKey regKey = localMachine .OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
regKey.SetValue("Shell", "explorer.exe", RegistryValueKind.String);
regKey.Close();