0

I am running into a weird situation.

I want to know if this registry key by running:

Test-Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\RefCount\SQLSysClrTypes12"

This registry does exist on my testing machine. If I run this script using the PowerShell console (%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe), it will return true.

BUT

If I run this script by first open Command Prompt, then run PowerShell (C:\Windows\system32>C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe)

then it won't find the registry key.

I also tried some other registry key, some of them work for both host. I also tested it under admin mode, doesn't make a different.

What the different between these PowerShell executables (32 bit vs 64 bit)?

Why would one return a different result than the other (do they have different access to the Registry)?

The reason I run into this is I am developing a script using the default PowerShell ISE, but when I translate it into a custom action in Advanced Installer, it would use the powershell in SysWOW64, and fail to find the key.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
dsum
  • 1,433
  • 1
  • 14
  • 29
  • So, in Advance Installer, you can specify if the script is a 64-bit script, which change which powershell.exe to run. I guess my main problem has solved. However, I still like to know why? The registry key is for SQL Server 2012 64 bit, will this going to work if I install SQL Server 2012 32 bit – dsum Jan 06 '17 at 21:30
  • 1
    Possible duplicate of [How to access the 64-bit registry from a 32-bit Powershell instance?](http://stackoverflow.com/questions/630382/how-to-access-the-64-bit-registry-from-a-32-bit-powershell-instance) – Tony Hinkle Jan 09 '17 at 14:18

1 Answers1

1

Windows maintains two separate sections in the registry for 32-bit and 64-bit applications.

See 32-bit and 64-bit Application Data in the Registry for more information.

Tony Hinkle
  • 4,706
  • 7
  • 23
  • 35
  • Thanks for the info. I found another related stackoverflow question: http://stackoverflow.com/questions/630382/how-to-access-the-64-bit-registry-from-a-32-bit-powershell-instance – dsum Jan 06 '17 at 22:46