title: How do you read a registry value using a custom msbuild task?
body: <p>I'm creating an MSBuild task that will read the registry for a specific registry key.  If I write the same line of code (see below) in a console application, it returns the expected result, but when it is within the MSBuild task, it returns nothing.  </p>
  
  <pre><code>Return Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\", "SQLPath", Nothing)
  </code></pre>
  
  <p>I would expect the above code to return <code>Nothing</code> if the key/value pair doesn't exist, and return the value if it does exist.  I am getting <code>Nothing</code> when the MSBuild task gets executed.  Is there some attribute that I need to apply to the Execute function of the MSBuild task to tell it that it needs to read the registry?  </p>
  
  <p><Strong>EDIT:</Strong></p>
  
  <p>Here is what is being executed from the MSBuild task: </p>
  
  <pre><code>Return Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Setup\", "SQLPath", Nothing)
  </code></pre>
  
  <p>I beleive this to be caused by the <a href="http://msdn.microsoft.com/en-us/library/aa384232(VS.85).aspx" rel="nofollow noreferrer">Registry Redirector</a> on my Vista x64 machine running MSBuild in 32bit.  Is there any way that you can tell the custom MSBuild task (written in VB .Net) to look in <code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\</code> then only if nothing exists there then look in <code>HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Setup\</code>?</p>
  
  <p>Thank you, </p>
  
  <p>Scott Blue </p>