64 位 Vista 中的批处理文件查询注册表 [英] Batch File Querying Registry in 64-Bit Vista

查看:21
本文介绍了64 位 Vista 中的批处理文件查询注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好 :) 我写的批处理文件有问题.它在 32 位上运行良好,但显然在 64 位系统上不起作用,我不知道为什么,因为我无法访问 64 位系统.

这是适用于Vista 32位系统的代码

 @echo off设置 Reg.Key=HKLMSOFTWAREMalwarebytes' Anti-Malware设置 Reg.Val=InstallPath对于/F "Tokens=2*" %%A In ('Reg 查询 "%Reg.Key%"/v "%Reg.Val%" ^|查找/I "%Reg.Val%"') 调用设置 MBAMPATH=%%B

有人可以重写它以在 64 位上运行吗?

永远感谢:)

解决方案

x86 和 x64 版本的 Windows 上的批处理文件没有区别.您遇到的问题是由于 WoW64 和透明注册表重定向,请参阅此处了解更多详情.>

HKLMSOFTWAREWow6432Node 是 64 位 Windows 安装上 32 位软件的正确注册表项,此代码适用于我的机器:

Set Reg.Key=HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMalwarebytes' Anti-Malware设置 Reg.Val=InstallPath对于/F "Tokens=2*" %%A In ('Reg 查询 "%Reg.Key%"/v "%Reg.Val%" ^|查找/I "%Reg.Val%"' )调用 Set MBAMPATH=%%B回声%mbampath%

您的另一篇文章包含一个基于 %processor_architecture% 环境变量的条件分支.问题在于(至少在我的机器上)%processor_architecture%"AMD64" 而不是 "x64".

为什么不只查询两个可能的注册表项,而不是基于架构进行分支?

Hi guys me again :) I have a problem with a batch file I wrote. It works fine on 32-bit, but apparently it doesn't work on 64-bit systems, and I don't know why because I do not have access to a 64-bit system.

This is the code that works on Vista 32-bit system

    @echo off
Set Reg.Key=HKLMSOFTWAREMalwarebytes' Anti-Malware
  Set Reg.Val=InstallPath
  For /F "Tokens=2*" %%A In (
   'Reg Query "%Reg.Key%" /v "%Reg.Val%" ^| Find /I "%Reg.Val%"'
  ) Do Call Set MBAMPATH=%%B

Can someone re-write it to work on a 64-bit please?

Thanks always :)

解决方案

There's no difference between batch files on x86 and x64 versions of Windows. The problem you have is due to WoW64 and transparent Registry redirection, see here for more details.

HKLMSOFTWAREWow6432Node is the correct registry key for 32bit software on a 64bit installation of Windows, and this code works on my machine:

Set Reg.Key=HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMalwarebytes' Anti-Malware
Set Reg.Val=InstallPath
For /F "Tokens=2*" %%A In (
    'Reg Query "%Reg.Key%" /v "%Reg.Val%" ^| Find /I "%Reg.Val%"' )
Do Call Set MBAMPATH=%%B
echo %mbampath%

Your other post includes a conditional branch based on the %processor_architecture% environment variable. The problem with that is that (on my machine at least) %processor_architecture% is "AMD64" not "x64".

Why not just query both possible registry keys rather than branching based on architecture?

这篇关于64 位 Vista 中的批处理文件查询注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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