如何在不重定向到 WOW6432Node 的情况下使用 32 位 Powershell 访问 64 位注册表项 [英] How to access a 64Bit Registry key using 32Bit Powershell without Redirection to WOW6432Node

查看:22
本文介绍了如何在不重定向到 WOW6432Node 的情况下使用 32 位 Powershell 访问 64 位注册表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简短的 Powershell 脚本,它应该在以下注册表路径中设置一个值:

I have a short Powershell-script that is supposed to set a value in the following registry-path:

Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Accessibility"  -Name "Configuration" -Value "osk"

我的问题是,脚本可以工作,但是当它从 32 位环境运行时(实际上我们使用自动调用脚本的 32 位自定义应用程序),调用被重定向到

My problem is, that the script works, but when it is run from a 32-Bit environment (actually we use a 32-Bit custom application that calls the scripts automatically), the call gets redirected to

HKEY_LOCAL_MACHINE\SOFTWARE\ WOW6432Node\Microsoft\Windows NT\CurrentVersion\Accessibility

HKEY_LOCAL_MACHINE\SOFTWARE\ WOW6432Node\Microsoft\Windows NT\CurrentVersion\Accessibility

并且该项目设置在那里,因此它无法正常工作.

And the item is set there, therefor it is not working as it is supposed to.

如何在 32 位和 64 位 Windows 10 系统上访问正确的注册表路径 HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Accessibility,无论脚本是从 32 位还是 64 位运行位命令外壳?

How can I reach the correct registry path HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Accessibility on both 32- and 64-Bit Windows 10 systems, no matter if the script is run from a 32- or 64-Bit commandshell?

推荐答案

看来你可以只测试系统的 64 位兼容性,然后相应地提供正确的参数值:

It seems you could just test the system for 64-bit compatibility, and then provide the proper parameter values accordingly:

if ([Environment]::Is64BitOperatingSystem) {
    Set-ItemProperty "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\Accessibility"  -Name "Configuration" -Value "osk"
}
else {
    Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Accessibility"  -Name "Configuration" -Value "osk"
}

这篇关于如何在不重定向到 WOW6432Node 的情况下使用 32 位 Powershell 访问 64 位注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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