1

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, therefor 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- and 64-Bit Windows 10 systems, no matter if the script is run from a 32- or 64-Bit commandshell?

Erik
  • 2,316
  • 9
  • 36
  • 58

2 Answers2

1

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"
}
AdminOfThings
  • 23,946
  • 4
  • 17
  • 27
  • Sorry, I think you misunderstood: I always want the values to go to Software\Microsoft, the WOW3264node is added by the OS automatically if run from 32Bit environment. – Erik Jul 18 '19 at 12:10
0

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
js2010
  • 23,033
  • 6
  • 64
  • 66