How to access the 64-bit registry from a 32-bit Powershell instance?

后端 未结 8 1209
北荒
北荒 2020-12-06 09:54

If you launch a 32-bit instance of Powershell (%SystemRoot%\\syswow64\\WindowsPowerShell\\v1.0\\powershell.exe), then the registry provider only sees the limited 32-bit part

8条回答
  •  误落风尘
    2020-12-06 10:28

    With .NET API you can read 64-bit values like this:

    $key = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry64)
    $subKey =  $key.OpenSubKey("SOFTWARE\Microsoft\.NETFramework")
    $root = $subKey.GetValue("InstallRoot")
    

提交回复
热议问题