OKAY - I finally have it. For posterity and for others trying to do this, I'll log it here.
My uninstaller dialog asks the user if they want to remove SQL server express, if its installed. To achieve this I:
1. Wrote a bat file to remove SQL server, the SQL server tools, and the SQL Helper packages, and then delete itself. Here's the code:
Code: Select all
msiexec.exe /x "{2AFFFDD7-ED85-4A90-8C52-5DA9EBDC9B8F}" /qb
msiexec.exe /x "{2750B389-A2D2-4953-99CA-27C1F2A8E6FD}" /qb
msiexec.exe /x "{53F5C3EE-05ED-4830-994B-50B2F0D50FCE}" /qb
del removesql.bat
Note that you should look up and verify the product codes above - they might have changed for your version of SQL.
2. I include this file on the install. I put it into the System folder, so that I'm sure it stays around and stays semi-hidden.
3. Under Organization / Components, I've set this BAT file to be permanent. This way, it doesn't go away during the uninstall, which is very important.
4. During uninstall, I added a checkbox that the user has to check to tell me they want to remove SQL. (UNINSTALL_SQL)
5. I added a custom action to the InstallFinalize action, a "New Installed Custom Action" that maps to my BAT file in the system folder, and which has the Execution Properties set to "Asynchronous Execution, do not wait for return" and has an execution condition of: REMOVE="ALL" and UNINSTALL_SQL=1
If your app creates a new database on SQL Server, you might also need to remove your database files with another custom action via VBS. Here's mine.
Code: Select all
function removeSQL()
dim pathToFolder, root, subfolder, dbpath, logpath, objFS
Set objFS = CreateObject("Scripting.FileSystemObject")
pathToFolder = Session.Property("ProgramFilesFolder")
pathToFolder = pathToFolder + "Microsoft SQL Server"
if objFS.FolderExists(pathToFolder) then
set root = objFS.GetFolder(pathToFolder)
for each subfolder in root.Subfolders
dbpath = subfolder.Path + "/MSSQL/DATA/YOURDB.mdf"
logpath = subfolder.Path + "/MSSQL/DATA/YOURDB_log.ldf"
if objFs.FileExists(dbpath) = True then objFs.DeleteFile dbpath, True
if objFs.FileExists(logpath) = True then objFs.DeleteFile logpath, True
Next
end if
end function
Hope that helps someone else.
FOLLOW US
Get the latest news in Application Packaging