rdavisunr
Posts: 5
Joined: Mon Sep 17, 2012 4:26 pm

Restart Windows Service after AI_MAINT

Hello

First, great job on the AI product! For someone with no experience in the installer arena, I have been able to create something very powerful in a short amount of time.

There is just one thing I cannot seem to figure out...

(using AI version 7.7)

I have created a custom dialog that lives in the Maintenance section and is invoked when the user clicks the "Modify" button on the MaintenanceTypeDlg. This dialog essentially allows the user to edit several values in a configuration file on disk. After modification, I would like AI to restart a Windows Service that was installed (and started) as part of the Install sequence.

Unfortunately, I cannot seem to make AI perform this task via the service "Control Operation". I am guessing this is because service control operations are not triggered during the AI_MAINT phase?

Trying to take another route, I was able to Terminate the windows service process using the pre-defined "Terminate Process" custom action. However, there didn't seem to be an option to start a process? Either way, this felt like I was circumventing built-in AI behavior for services.

TL;DR

How do I restart a running Windows service after modification (AI_MAINT) using Advanced Installer best practices?

Cheers,
Rob
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Restart Windows Service after AI_MAINT

Hello Rob and welcome to Advanced Installer forums,

In order to achieve what you want you can use the "sc.exe" utility with a "Launch File or Open URL" custom action to launch the command lines that stop and start the service on maintenance mode. Please take a look on our "How do I launch a CMD or BAT file?" article.

Also, the related custom action should be scheduled after "Install Execution Stage" -> "Add Resources" action group and should run as "Deferred with no impersonation".

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rdavisunr
Posts: 5
Joined: Mon Sep 17, 2012 4:26 pm

Re: Restart Windows Service after AI_MAINT

Daniel

Thank you for your advice! Your suggestion worked very well!!

I have an additional question if you don't mind...

In each of the new Custom Actions (for starting/stopping of services), I am checking the following "execution condition" to make sure the actions are ONLY executed in the case of a modification in maintenance mode.

(Installed) AND (Not (REMOVE="ALL"))

Is there a more concise way to specify this?

Best regards,
Rob
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Restart Windows Service after AI_MAINT

Hello Rob,

In order to obtain what you want you can use the following condition:

Code: Select all

AI_INSTALL_MODE = "Change"
All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”