为什么双击批处理文件找不到要删除的注册表值? [英] Why can a double clicked batch file not find a registry value for deletion?

查看:66
本文介绍了为什么双击批处理文件找不到要删除的注册表值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个bat文件来删除注册表项.

I wrote a bat file to delete an registry entry.

reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v VALUE /f

当我在cmd中执行时,它可以工作.

When I execute in cmd, it works.

但是当我双击执行它时,它不会!

But when I execute it by double click, it doesn't!!!

错误消息:

Error: the system could not find the specified registry keys or values

其他任何人都可以告诉我为什么!

Anyone else can tell me why!

推荐答案

在64位Windows上,可以自动启动64位应用程序

On 64-bit Windows there is for automatic start of 64-bit applications

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run

并用于自动启动32位应用程序

and for automatic start of 32-bit applications

HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Windows \ CurrentVersion \ Run

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run

如果批处理文件由目录%SystemRoot%\ System32 \ 中的32位 cmd.exe 执行,则会自动将32位应用程序重定向到%SystemRoot%\ SysWOW64 \ ,注册表路径

If the batch file is executed by 32-bit cmd.exe in directory %SystemRoot%\System32\ being automatically redirected for 32-bit applications to %SystemRoot%\SysWOW64\, the registry path

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run

会自动重定向到

HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ Windows \ CurrentVersion \ Run

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run

如果批处理文件由目录%SystemRoot%\ System32 \ 中的64位 cmd.exe 执行,则可以由Windows上的32位应用程序调用x64使用重定向器%SystemRoot%\ Sysnative \ 代替注册表路径%SystemRoot%\ System32 \

If the batch file is executed by 64-bit cmd.exe in directory %SystemRoot%\System32\, which can be called by 32-bit applications on Windows x64 using redirector %SystemRoot%\Sysnative\ instead of %SystemRoot%\System32\, the registry path

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run

确实是在引用

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run

因此,我假设 Run 键中的 VALUE 存在于32位应用程序(在Wow6432Node之下),但是双击时的批处理文件是由64位 cmd.exe ,因为使用了64位Windows资源管理器.因此,对于64位应用程序,在运行键中找不到该值.

So I suppose that VALUE exists in Run key for 32-bit applications (below Wow6432Node), but the batch file on double click is executed by 64-bit cmd.exe because 64-bit Windows Explorer is used. Therefore the value cannot be found in Run key for 64-bit applications.

解决方案是使用

%SystemRoot%\Sysnative\reg.exe delete HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run /v VALUE /f

请注意,特殊重定向器%SystemRoot%\ Sysnative \ 仅在64位Windows和32位应用程序中存在,而在32位Windows中不存在.如果该批处理文件也适用于32位Windows,则应考虑到这一点.

Please note that special redirector %SystemRoot%\Sysnative\ exists only on 64-bit Windows and only for 32-bit applications, but does not exist on 32-bit Windows. Take that into consideration if the batch file should work also for 32-bit Windows.

有关Windows x64上重定向的更多信息,请阅读Microsoft文档页面:

For more information about redirections on Windows x64 read the Microsoft documentation pages:

这篇关于为什么双击批处理文件找不到要删除的注册表值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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