Roman B.
Posts: 5
Joined: Thu Apr 05, 2012 8:31 am

Stopping service on uninstall before executing SQL scripts

Hi.

The installation package I'm trying to create includes services that access SQL DB. These DBs are created during installation by SQL scripts I supply to AI and are dropped by other SQL scripts which are scheduled to run during uninstall.

What I see is that the installation SQL script executes successfully but the uninstall SQL script fails to drop the DB, probably because the service (which is being uninstalled) is still running and uses the DB.

My question: how can I make the service stop before the SQL scripts execution step?


Thanks in advance.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Stopping service on uninstall before executing SQL scrip

Hi Roman and welcome to Advanced Installer forums,

If you want to stop a service on uninstall before the sql scripts execution then you must schedule the "AI_SqlUninstall" action after "DeleteServices" action. This can be achieved by editing your .AIP file. You can edit the .AIP with NOTEPAD (select .AIP file and from the context menu choose "Edit with NOTEPAD" option).
Now search for:

Code: Select all

 <COMPONENT cid="caphyon.advinst.msicomp.MsiInstExSeqComponent">

node and in the:

Code: Select all

<ROW Action="AI_SqlUninstall" Condition="(VersionNT >= 500) AND (REMOVE="ALL")" Sequence="1649"/>

edit the sequence number to "2001". It must be changed to "2001" because the "StopServices" custom action has the sequence number set to "1900". In this manner your service should stop and get deleted before the SQL scripts execution.

Let us know if this helps, otherwise please give us more details about your scenario.

Regards,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Roman B.
Posts: 5
Joined: Thu Apr 05, 2012 8:31 am

Re: Stopping service on uninstall before executing SQL scrip

Hello Mihai.

Thank you for the greeting.

Your suggestion was very helpful. It now works as I expect it.

Thanks for the help and for the quick reply.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Stopping service on uninstall before executing SQL scrip

You're welcome Roman, glad to help.

Return to “Building Installers”