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: https://stackoverflow.com/questions/16068490/how-do-i-remove-an-sql-2008-instance-from-command-prompt-w-o-removing-the-server), but the hard part is reliably finding setup.exe.
I've found copies of setup.exe in
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\
and finally I found "setup100.exe" in
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2\x86
How do I know which one to use? So far I've found I have to use the one in:
C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\
but I'm still not sure why I found a setup.exe in that SQLServer2008R2 folder.
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.
Right now I'm just querying the DB for it's install location, using what I find in
"\100\Setup Bootstrap\setup.exe"
and hoping for the best :P.
Edit: Found another one :P
"C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Release\x86\setup100.exe"