lidds
Posts: 44
Joined: Thu Jun 14, 2012 11:22 pm

Uninstall SQL Instance....

What I want to do is detect if a SQL Server Instance which is named "RISSQL" exists on the machine that the installer is running on, and if it does STOP this service and uninstall just this service.

I want to do this during the uninstall process of my application, and would have to be done prior to uninstalling my application.

Would it be possible to explain how to do this??

Thanks

Simon
CiprianComsa
Posts: 110
Joined: Thu Aug 19, 2010 10:11 am
Contact: Website

Re: Uninstall SQL Instance....

Hi Simon,

You can create custom action that runs during uninstall.
That custom action would launch a command line sql tool that would remove the named instance.
Please refer to sql server's documentation on how to remove a named instance through the command line.

Regards,
Ciprian
__________________________________________________________________________________________________________________________________________________
Ciprian Comsa
Advanced Installer Team
http://www.advancedinstaller.com/
Ciprian Comsa - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
lidds
Posts: 44
Joined: Thu Jun 14, 2012 11:22 pm

Re: Uninstall SQL Instance....

Ciprian,

Thanks for the information. I have had a look at the SQL Documentation and that makes sense, using the following:

Setup.exe /Action=Uninstall /FEATURES=SQL,AS,RS,IS,Tools /INSTANCENAME=MSSQLSERVER

The only problem I now have is determining where the SQL Server Setup.exe file is located. With my installer it always downloads SQL Server Express as a prerequisite, but how do I interigate advanced installer to get the directory location of the downloaded prerequisite? As I could need to add the directory location to the syntax e.g.:

C:\Documents and Setting\User\Simon\Prerequisites\SQLExpress\Setup.exe /Action=Uninstall /FEATURES=SQL,AS,RS,IS,Tools /INSTANCENAME=MSSQLSERVER

Thanks

Simon
CiprianComsa
Posts: 110
Joined: Thu Aug 19, 2010 10:11 am
Contact: Website

Re: Uninstall SQL Instance....

Hi Simon,

You could just look for the path directly from the SQL Server Registry location:

Code: Select all

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\ClientSetup\path
Please note, this path is not the same for each SQL Server.
To achieve this with AdvancedInstaller go to Search Page and add a New Search and name it for example SQLCMD. Right-click on the search and select "Add Location -> Registry" and specify the registry key.
Also, use the "Test Search" toolbar button in order to make sure the Search is configured correctly.

In the Custom Actions page, create a new "Launch EXE with working directory" Custom Action with the following parameters:

Working Dir: (any)
Full Path: "[SQLCMD]" and your command line parameters

Execution Condition: (Not Installed) AND SQLCMD

Regards,
Ciprian
__________________________________________________________________________________________________________________________________________________
Ciprian Comsa
Advanced Installer Team
http://www.advancedinstaller.com/
Ciprian Comsa - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”