seppork
Posts:15
Joined:Tue Jul 03, 2007 8:12 pm
Conditionally prevent installation if a service exists

Mon Nov 05, 2018 1:00 pm

Hi!

I need to stop the current installation altogether if the target computer has mySQL service or mySQL database installed.
How to achieve this?

Regards
Seppo RK

Catalin
Posts:4423
Joined:Wed Jun 13, 2018 7:49 am

Re: Conditionally prevent installation if a service exists

Mon Nov 05, 2018 2:38 pm

Hello Seppo,

In order to achieve this, you can use our predefined support for "DetectService" custom action. To do so, please go to "Custom Actions" page and add a "DetectService" custom action with sequence (simply press the "Add custom action with sequence" button which is placed on the right side of the custom action's name).

Uncheck the "Uninstall" and "Maintenance" options from under the "Execution Stage Condition".

Please be careful not to use the service display name, but it's real name instead. To get a service name, please proceed as it follows:

- Open a "Run" window by pressing the Win+R buttons combination.

- Type: services.msc

- Look up for your service --> right click on it --> "Properties" --> "Service name:"

The "DetectService" custom aciton initializes a property ([AI_SERVICE_STATE]) with the following values:

- "Started"
- "Stopped"
- "Not Found"

Now we have to schedule it before the "Paths Resolution" action group --> "Wizard Dialogs Stage". To do so, simply drag and drop it before the specified action group.

Now that we have created the custom action, all we have to do is to create a custom launch condition based on that. To do so, please proceed as it follows:

- Go to "Launch Conditions" page --> "Custom" tab

- Press "New..." and in the "Condition" field please insert the following condition:

Code: Select all

AI_SERVICE_STATE = "Not Found" 
(We only want to install our setup when the SQL is not installed --> the service is not found)

Hope this helps.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

seppork
Posts:15
Joined:Tue Jul 03, 2007 8:12 pm

Re: Conditionally prevent installation if a service exists

Mon Nov 05, 2018 7:18 pm

Thanks!!!

That's something I'd never had found out without your detailed instructions - it works now!

- best regards Seppo RK

seppork
Posts:15
Joined:Tue Jul 03, 2007 8:12 pm

Re: Conditionally prevent installation if a service exists

Mon Nov 05, 2018 8:54 pm

Hi again!

Well ...the solution works so perfectly that it prevents the installation even if the service does not exist.
What did I do wrong?

Attached some screenshots - see below.
1: Custom action Detect service - MySql
2: Launch conditions.
3: Services in the target computer & Service name is MySQL in – checked from my development computer.

By the way, I noticed that the custom action help text says "This custom action will fill AI_SERVICE_STATE with Started ... or Stopped , not mentioning *Not Found*

Tried to change the service name to a fake - nonexistent one -> aborted installation
Tried service state *Started* and *Stopped* -> aborted installation
Restarted the target computer -> no success
The target computer does not even have the directory \..\mysql\bin which would contain the MySql service installation utility.

Can you find what went wrong?

Regards
Seppo RK
Attachments
scShot2.png
scShot2.png (60.67KiB)Viewed 8458 times
scShot1.png
scShot1.png (177.66KiB)Viewed 8458 times
scShot3.png
scShot3.png (98.81KiB)Viewed 8458 times

Catalin
Posts:4423
Joined:Wed Jun 13, 2018 7:49 am

Re: Conditionally prevent installation if a service exists

Tue Nov 06, 2018 9:15 am

Hello Seppo,

Almost everything is configured fine. The only thing that is missing is the fact that you must share the "DetectService" custom action between the two stages ("Wizard Dialogs Stage" and "Install Execution Stage"). If you read my previous thread again carefully, you will notice that I have said you should schedule the custom action before "Paths Resolution", but in "Wizard Dialogs Stage". The only thing you have to do now is press SHIFT + drag and drop (share) your custom action from "Install Execution Stage" to "Wizard Dialogs Stage".

The reason why the launch condition failed even if the service was not found on the system is because is because, at the point (in time) when the launch condition was evaluated, the "DetectService" custom action have not yet taken place (did not run), resulting in the property (AI_SERVICE_STATE) being empty which further results in the launch condition failing.

Attached you can find a screenshot which displays how the custom action should look after you share them between the two stages.
SharedCA.PNG
SharedCA.PNG (21.92KiB)Viewed 8451 times
Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

seppork
Posts:15
Joined:Tue Jul 03, 2007 8:12 pm

Re: Conditionally prevent installation if a service exists

Tue Nov 06, 2018 1:54 pm

HI!

Thanks!
Now it runs!

- Seppo RK

Catalin
Posts:4423
Joined:Wed Jun 13, 2018 7:49 am

Re: Conditionally prevent installation if a service exists

Tue Nov 06, 2018 1:58 pm

Hello Seppo,

You're always welcome. I am glad you got this working.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

ptssi
Posts:2
Joined:Thu Sep 09, 2021 6:19 am

Re: Conditionally prevent installation if a service exists

Thu Sep 09, 2021 6:51 am

Hi,
I work with trial version 18.6.1.
I encountered same situation that AI_SERVICE_STATE returns empty with custom Launch Condition AI_SERVICE_STATE = "Not Found".
Could you let me know what's wrong with my settings?
Here I attach two images (one for Launch Condition, one for Custom Actions).
Attachments
LaunchCondition 2021-09-08 223839.png
LaunchCondition 2021-09-08 223839.png (9.89KiB)Viewed 6666 times
CustomAction 2021-09-08 224007.png
CustomAction 2021-09-08 224007.png (67.02KiB)Viewed 6666 times

Liviu
Posts:150
Joined:Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Conditionally prevent installation if a service exists

Thu Sep 09, 2021 10:26 am

Hi,
I work with trial version 18.6.1.
I encountered same situation that AI_SERVICE_STATE returns empty with custom Launch Condition AI_SERVICE_STATE = "Not Found".
Could you let me know what's wrong with my settings?
Here I attach two images (one for Launch Condition, one for Custom Actions).
Hi and welcome to our forums,

I've tested your scenario, but I cannot reproduce the behavior, everything works as expected. 

Can you please send us by email to support at advancedinstaller dot com so we can further test and investigate this, the following resources:
  1. the .AIP (setup project) file.
  2. an installation log.
  3. a screenshot with the Service properties like this:
    ServiceProp.png
    ServiceProp.png (64.61KiB)Viewed 6649 times
    You need to make sure that the service name is correct.
Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

ptssi
Posts:2
Joined:Thu Sep 09, 2021 6:19 am

Re: Conditionally prevent installation if a service exists

Fri Sep 17, 2021 8:19 am

Thanks for your comments.
I found that my computer was corrupted with old installer.
Please close my case.

Liviu
Posts:150
Joined:Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Conditionally prevent installation if a service exists

Fri Sep 17, 2021 8:37 am

Thanks for your comments.
I found that my computer was corrupted with old installer.
Please close my case.
Hi,

Thank you for your follow-up on this.

I'm glad you solved the issue.

Please let us know if there is anything else we could help you with and we will gladly assist.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”