How to access a 64-bit Registry key using 32-bit Powershell without Redirection to WOW6432Node

3.8k views Asked by At

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"

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

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

How can I reach the correct registry path:

HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Accessibility

on both 32-bit and 64-bit Windows 10 systems, no matter if the script is run from a 32-bit or 64-bit command-shell?

2

There are 2 answers

1
AdminOfThings On

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"
}
0
js2010 On

Are you using Kace, which has only a 32-bit client? :/ You can run the 64-bit powershell like this from it:

C:\WINDOWS\Sysnative\WindowsPowerShell\v1.0\powershell.exe