title: installer registry access in windows server 2012
body: <p>I have a custom action in an Installshield Basic MSI project to find out the version of SQL Server from registry.</p>
  
  <pre><code>RegKey2012 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\" &amp; _
               "Microsoft SQL Server\MSSQL11.MSSQLSERVER\"
  If RegKeyExists(RegKey2012) Then 
    WScript.StdOut.Write("2012") 
  Else 
    WScript.StdOut.Write("2008R2") 
  End If 
  
  Function RegKeyExists(Key) 
    Dim oShell, entry 
    On Error Resume Next 
    Set oShell = CreateObject("WScript.Shell") 
    entry = oShell.RegRead(Key) 
    If Err.Number &lt;&gt; 0 Then 
      Err.Clear 
      RegKeyExists = False 
    Else 
      Err.Clear 
      RegKeyExists = True 
    End If 
  End Function
  </code></pre>
  
  <p>The installer works fine on a Windows 7 machine. The above script works fine in isolation on a Windows Server 2012 machine. However when I run the installer (as ADMIN) on windows server 2012, it does not work as expected and the error description is - It cannot find the registry key. </p>
  
  <p>Any ideas.</p>