MLiss@Cetrus.com
Posts: 366
Joined: Wed Dec 30, 2015 5:40 pm

Make call into service

Thu Jun 28, 2018 5:02 pm

Hi,

I would like to be able to notify my service when the installer is uninstalling the service.

Is this possible?

MLiss@Cetrus.com
Posts: 366
Joined: Wed Dec 30, 2015 5:40 pm

Re: Make call into service

Thu Jun 28, 2018 5:22 pm

I found a way to receive a custom command in my service:

protected override void OnCustomCommand(int command)
{
base.OnCustomCommand(command);
}

I just need to know how to send it to my service FROM the installer:

ServiceController sc = new ServiceController(“MyService”);
sc.ExecuteCommand(255);

MLiss@Cetrus.com
Posts: 366
Joined: Wed Dec 30, 2015 5:40 pm

Re: Make call into service

Thu Jun 28, 2018 6:20 pm

I think it would be in a launch file?
sc
control <servicename> <value> ???

MLiss@Cetrus.com
Posts: 366
Joined: Wed Dec 30, 2015 5:40 pm

Re: Make call into service

Thu Jun 28, 2018 9:55 pm

So I put the "control" call into the Launch File command, ran the installer and got this:
-
MSI (s) (78:D4) [13:37:29:031]: Doing action: LaunchFile_Install
Action start 13:37:29: LaunchFile_Install.
CustomAction LaunchFile_Install returned actual error code 1062 (note this may not be 100% accurate if translation happened inside sandbox)
MSI (s) (78:D4) [13:37:45:655]: Note: 1: 1722 2: LaunchFile_Install 3: C:\Windows\Installer\MSIFA4B.tmp 4: /RunAsAdmin /HideWindow sc control CetrusAgentService 128
Info 2898. For DlgFont8 textstyle, the system created a 'Tahoma' font, in 0 character set.
MSI (s) (78:D4) [13:37:54:959]: Product: Cetrus Agent Service -- Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action LaunchFile_Install, location: C:\Windows\Installer\MSIFA4B.tmp, command: /RunAsAdmin /HideWindow sc control CetrusAgentService 128

Action ended 13:37:54: LaunchFile_Install. Return value 3.
Action ended 13:37:54: INSTALL. Return value 3.

MLiss@Cetrus.com
Posts: 366
Joined: Wed Dec 30, 2015 5:40 pm

Re: Make call into service

Thu Jun 28, 2018 9:58 pm

Here are my settings
LaunchFile_Install.PNG
LaunchFile_Install.PNG (62.8KiB)Viewed 7133 times

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Make call into service

Mon Jul 02, 2018 6:56 pm

Hello Mike,

I apologize for the delayed reply.

Could you please try calling sc.exe tool through a BAT file and see if this helps? For instance, you can create a BAT file with the following content:

Code: Select all

sc control serviceName 128
and then add the BAT file as a temporary file into your setup project and execute the BAT through a "Launch File" custom action too.

Let us know if this helped.

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

MLiss@Cetrus.com
Posts: 366
Joined: Wed Dec 30, 2015 5:40 pm

Re: Make call into service

Mon Jul 02, 2018 8:05 pm

Daniel,

What is strange it works on the uninstall side... but not on the install side

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Make call into service

Thu Jul 05, 2018 3:52 pm

Hello Mike,

This is strange indeed. For the moment I have no clue why this happens. Maybe it has something to do with the fact that the custom action call is triggered within the same process as the one which effectively installs the service too.

Please give me some more time to further test and investigate this scenario and as soon as I have a conclusion I will get back with updates.

Thank you for your patience and understanding.

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

MLiss@Cetrus.com
Posts: 366
Joined: Wed Dec 30, 2015 5:40 pm

Re: Make call into service

Thu Jul 05, 2018 9:52 pm

Daniel,

Thank you ... much appreciated !

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Make call into service

Tue Jul 10, 2018 11:48 am

Hello Mike,

I have tested your installation scenario and a service notification control was successfully sent to a service whithin the same installation process that installed the service too. Also, the service installation was launched within another custom action too.

I am not sure why this does not work in your case too. Can you please make sure that your service was successfully installed and started by the moment your control notification custom action was launched? For troubleshooting this you can simply add a message box custom action just before your service control notification action and when the message box is thrown you can check in the system Service Manage that your service was correctly installed and started.

Maybe this helps.

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

MLiss@Cetrus.com
Posts: 366
Joined: Wed Dec 30, 2015 5:40 pm

Re: Make call into service

Wed Jul 11, 2018 7:34 pm

thanks... I will do some more testing

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Make call into service

Mon Jul 30, 2018 8:39 am

You are welcome Mike.

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

Return to “Building Installers”