以编程方式更改 Windows Shell
我正在开发一个将“嵌入”到 Windows 7 系统中的项目,这将通过禁用任务管理器并将 Windows shell 更改为应用程序以及其他操作来实现。
我想要在这里做的是以编程方式更改应用程序和 explorer.exe 之间的 Windows shell,我想知道是否有任何方法可以在 C# 中执行此操作。
目前,我有几行代码尝试更改 Windows Shell 的注册表项,但刷新注册表编辑器后似乎没有任何反应,代码如下所示:
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", true).OpenSubKey("Microsoft", true).OpenSubKey("Windows NT", true).OpenSubKey("CurrentVersion", true).OpenSubKey("Winlogon", true);
regKey.DeleteValue("Shell");
regKey.SetValue("Shell", shell);
regKey.Close();
我尝试重新启动 Windows 以查看是否允许 shell更改完成,但无济于事。
如果有人能告诉我是否可以通过编程来完成它,以及我哪里出错了,我将不胜感激。
另外,我很高兴知道是否有一种方法可以对程序进行编码,以便它始终以管理员权限运行,以便注册表编辑可以工作。
非常感谢,
理查德
I'm working on a project that will be "embedded" into a Windows 7 system, this is going to be achieved by disabling task manager and changing the windows shell to the application, as well as other things.
What I'm looking to do here is programmatically change the Windows shell between the application and explorer.exe, I would like to know if there's any way to do this in C#.
Currently I have a few lines of code that attempt to change the registry entry for the Windows Shell, but nothing appears to happen after refreshing the Registry Editor, the code looks like this:
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", true).OpenSubKey("Microsoft", true).OpenSubKey("Windows NT", true).OpenSubKey("CurrentVersion", true).OpenSubKey("Winlogon", true);
regKey.DeleteValue("Shell");
regKey.SetValue("Shell", shell);
regKey.Close();
I've tried restarting windows to see if that allows the shell change to complete, but to no avail.
I'd greatly appreciate it if someone can tell me if it's even possible to do it programmatically, and where I'm going wrong with it.
Also, I'd be grateful to know if there's a way to code the program so that it's always running with admin privileges so that registry editing will work.
Many Thanks,
Richard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过在网络上的其他位置进行大量搜索后,我终于将 Shell 更改为正在构建的应用程序的可执行文件。
“嵌入”过程是一个三步过程,对于我正在开发的软件,我们首先禁用任务管理器,然后在本地计算机注册表中设置 shell 可执行文件,然后在当前用户中重复该过程注册表。
下面是实现此目的的代码:
在此示例中,变量“shell”是一个字符串,其中包含用作新 Windows Shell 的可执行文件的路径。
除此之外,还有一种“取消嵌入”软件的方法,该方法只是从当前用户注册表中删除“DisableTaskMgr”和“Shell”值,还将本地计算机注册表中的“Shell”值重置为“explorer” 。EXE文件”。
我希望这可以帮助其他在以编程方式更改 Windows Shell 时遇到问题的人。
问候,
理查德
After much searching of other locations on the net, I have finally got the Shell to change to the executable file of the application that is being built.
The "Embedding" process is a three step process, in the case of the software I'm working on, we start by disabling Task Manager, We then set the shell executable in the Local Machine registry and then repeat the process in the Current User registry.
Below is the code that achieves this:
In this example the variable "shell" is a string containing the path of the executable to use as the new Windows Shell.
Further to this there's a method to "un-embed" the software, this method simply deletes the "DisableTaskMgr" and "Shell" values from the Current User registries, it also resets the "Shell" value in the Local Machine registry to "explorer.exe".
I hope this helps others out there who're having trouble changing Windows Shells programmatically.
Regards,
Richard