Rosacek
Posts: 9
Joined: Thu Feb 05, 2015 1:41 pm

How to start .NET service after installation

Hi,
I made installation for my .NET service.
It works fine with NET Installer Class

The only problem is the service does not start immediatelly after installation. I have to start it manually.
I can find "Stop service" in Custom Actions but I cannot find "Start service" there.
Or is it the only way to run "net start service" as described in http://www.advancedinstaller.com/user-g ... rvice.html ?
Daniel
Posts: 8239
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: How to start .NET service after installation

Hello,

To start your .NET service you can try to use a "Launch file" custom action with sequence, added after "Install Execution Stage -> Finish Execution" action group, scheduled like this:
  • File To Launch: cmd.exe
    Command Line: /c NET START "service name"
    Working Directory:
    Run as Adminsitrator: checked
Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Rosacek
Posts: 9
Joined: Thu Feb 05, 2015 1:41 pm

Re: How to start .NET service after installation

Start service works fine, thx.

I fight with uninstall now. I use Custom Action "Stop Service" and also tried to use cmd.exe /c NET STOP "service name"
In both cases I can see warning that I should reboot as some files are in use. Then uninstall finish fine.

When service is stopped it sends mail. It looks like I need additional 1 sec wait time after service is stopped and then continue in uninstalling to get avoid "some files are in use... reboot is neccessary" message.
Daniel
Posts: 8239
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: How to start .NET service after installation

You're welcome.

To delay a few seconds the uninstall process after stopping your service, you can create a BAT file which will stop your service and then will delay the execution with a few seconds. Then, you can run you BAT file by adding it as a temporary file and execute it using a "File to launch" custom action with sequence added after "Install Execution Stage -> Searches" action group.

Let us know if this helped.

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

Return to “Common Problems”