Find SQL 2008 setup.exe for command line uninstall

5.1k Views Asked by At

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"
1

There are 1 best solutions below

0
On

You can look in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\100\Bootstrap

The key you want is BootstrapDir.

FWIW, I don't have either (setup100.exe or setup.exe) in the Setup Bootstrap folder, only in the SQLServer2008R2 subfolder. This is perhaps because I don't have SQL Server 2008 installed, only 2008 R2.

So what do you plan to do when the file you're after is not found (either because 2008 isn't already installed, or because the user deleted it in an ill-advised attempt to free up some space)?