I want to check if a user has Microsoft SQL Native Client 2008 (sqlncli10) or Native Client 2012 (sqlncli11) installed.
Dim key As String
Dim myShell As Object
Set myShell = CreateObject("WScript.Shell")
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SQLNCLI11\CurrentVersion\Version"
'key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion"
Dim strKey As String
strKey = myShell.RegReadkey(key)
When looking for the native client I receive the error:
Invalid root in registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft SQL Server\SQLNCLI11\CurrentVersion\Version"
but when trying the Windows NT version it works fine.
I replaced HKEY_LOCAL_MACHINE with HKLM: but that doesn't work either.
EDIT
I just figured it out I think. When I checked in the registry it exists in the 64-bit section. However VBA checks in 32-bit and the root for SOFTWARE becomes Wow6432Node. So it checks in Wow6432Node\Microsoft\Microsoft SQL Server and the key does not exist there. But I have found another path SOFTWARE\Microsoft\Microsoft SQL Server Native Client 10 alternatively 11 which exist in both 32-bit and 64-bit.