Start an NT Service after install is complete - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

seifordd
Posts: 10
Joined: Tue Jun 28, 2011 4:05 pm

Start an NT Service after install is complete

My install is installing an NT service. I have used the Resources/Services functionality to define the service. When I run the MSI, the service gets installed and uninstalled as expected.

I would like to give the user an option to start the NT service on the Exit dialog. When I try checking the "Launch Application" check box on the Finish Actions of the ExitDialog, it asks for an EXE to run.

How do I start the NT service.

If I try running the NT service exe, I get an error saying you need to use the 'NET START' command to start an NT service.

I did check the 'Start' check box under the 'Event On Install' on the Services page. It didn't seem to have much affect.

Thanks,
Dave
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Start an NT Service after install is complete

Hi Dave,
I would like to give the user an option to start the NT service on the Exit dialog.
For this you need to use our built-in custom action "Launch File or Open URL", add it under "UI Custom Actions" in Custom Actions page. Set its "Command Line"
field to something like this:

Code: Select all

 net start "Service Name"
Now go to Dialogs page and create checkbox control on ExitDialog, after this add a Doaction published event on the "Finish" button. The event
must call the above custom action which you've just created and should use as a condition the property of the checbox, so it runs only if the checkbox is set.
I did check the 'Start' check box under the 'Event On Install' on the Services page. It didn't seem to have much affect.
This option decides if the service is started or not during the install process, it is executed before the user can see ExitDialog. To give the user the option
choose if he wants to start it or not you must not set no action for Install, in Services page, and use the custom action to start it.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
seifordd
Posts: 10
Joined: Tue Jun 28, 2011 4:05 pm

Re: Start an NT Service after install is complete

I defined my custom action under "UI Custom Actions".
And I entered "Net start 'thenameofmyservice'" in the Command Line field

What should I pick for the 'Source Path' and 'Source Type' fields?
How do I indicate the text in the Command Line field should be run in a command prompt?

Thanks,
Dave
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Start an NT Service after install is complete

Hi Dave,

Our user guide contains the Launch file after installation how-to which may help you. It uses a Launch file or open URL custom action to execute a command line.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
seifordd
Posts: 10
Joined: Tue Jun 28, 2011 4:05 pm

Re: Start an NT Service after install is complete

I got the custom action to to work. This is how I configured the Custom Action.

General Properties:
Source Path: <AI_CUSTACTS>viewer.exe
Source Type: Executable (*.exe)
Command Line: net start SOARServerServiceHost

On some servers, I have found I need to run this command to start the NT service in a command prompt as Administrator.

I found the Launch File as Admnistrator predefined UI custom action.
When I tried to configure it the same as the Custom action I described above, I ran into issues.

I can change the Source Type from the default of Dynamic Linked Library (*.dll) to Executable (*.exe) and enter my Command Line.
But what should I set the Source Path: entry to.
The default value is <AI_CUSTACTS>aicustact.dll.

If I click the "..." button and browse to where the viewer.exe is located. This is what is stored in the field.
C:\Program Files (x86)\Caphyon\Advanced Installer 8.2\custact\x64\viewer.exe
not
<AI_CUSTACTS>viewer.exe

How should I configure the Launch File as Administrator to get my 'net start SOARServerServiceHost' to run as Administrator

Thanks
Dave
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Start an NT Service after install is complete

Hi Dave,

To execute a custom action with Administrator privileges you can make it deferred with no impersonation. Please note that this can be done only for actions scheduled between InstallInitialize and InstallFinalize actions in InstallExecuteSequence.

If you want to use a launch file as an Administrator custom action, you need to configure it in a specific way. You can read more about this here:
http://www.advancedinstaller.com/user-g ... file-admin

Also, please note that you shouldn't modify the source information for predefined custom actions.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
seifordd
Posts: 10
Joined: Tue Jun 28, 2011 4:05 pm

Re: Start an NT Service after install is complete

I am still trying to figure out how to run a command to start a service and run it as Admin.
I saw the documentation on the UI custom action 'RunAsAdmin' but I can't figure out how to configure it to run the following command. 'net start SOARServerServiceHost'

I added a RunAsAdmin custom action but I don't see where I can enter the command I want run with Admin privileges.
Can you give the the steps required to define the RunAsAdmin command and where I define the command to run.
With the documentation I have seen, I can't figure out how to do it.

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

Re: Start an NT Service after install is complete

Hi Dave,

All you need to do is set the mentioned properties( SetProperty events ) before executing the custom action( DoAction event ).

However this custom action is not meant for your case.

Cosmin clearly underlined and explained how to achieve this functionality. Have you followed his suggestions and links( blue text ) from this thread?

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”