title: Find SQL 2008 setup.exe for command line uninstall
body: <p>I'm writing a little .Net app that stores data in a named SQL instance. I need to be able to uninstall the instance programatically. It's easy enough to call setup.exe with the uninstall parameters (I figured them out in this post: <a href="https://stackoverflow.com/questions/16068490/how-do-i-remove-an-sql-2008-instance-from-command-prompt-w-o-removing-the-server">https://stackoverflow.com/questions/16068490/how-do-i-remove-an-sql-2008-instance-from-command-prompt-w-o-removing-the-server</a>), but the hard part is reliably finding setup.exe.</p>
  
  <p>I've found copies of setup.exe in </p>
  
  <pre><code>C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\
  C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\
  </code></pre>
  
  <p>and finally I found "setup100.exe" in </p>
  
  <pre><code>C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\x86
  </code></pre>
  
  <p>How do I know which one to use? So far I've found I have to use the one in: </p>
  
  <pre><code>C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\
  </code></pre>
  
  <p>but I'm still not sure why I found a setup.exe in that SQLServer2008R2 folder. </p>
  
  <p>There are ways to query for the uninstall command but they're unreliable when you uninstalling a named instance... :(. Win32_Product works but it breaks things when it's called. Windows.Installer logs everything that was ever installed so if I've had a few versions of SQL installed (surprisingly common) I can't tell which to use. </p>
  
  <p>Right now I'm just querying the DB for it's install location, using what I find in </p>
  
  <pre><code>"\100\Setup Bootstrap\setup.exe" 
  </code></pre>
  
  <p>and hoping for the best :P.</p>
  
  <p>Edit: Found another one :P</p>
  
  <pre><code>"C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Release\x86\setup100.exe"
  </code></pre>