Uniwares_AS
Posts: 8
Joined: Thu Oct 04, 2007 1:03 am

Installing service under different account depending on OS

Right, I am trying to install a service either under the NETWORK SERVICE account if the operating system is Windows 2003 or later, but LOCALSYSTEM on any other OS.

Questions:
1) how do I set the condition for the service account setting?
2) what to put in the password field for the NETWORK SERVICE account?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

In order to condition the installation of the service you can use the components in the "Organization" page. These are the steps:
- in the"Custom Actions" page you create 2 "Property set with formatted" custom actions under the "InstallUISequence" -> "CostFinalize" folder (you can add the "CostFinalize" standard action by using the "Show standard action" button on the toolbar)
- the first custom action looks like this:

Code: Select all

Property Name: ACCOUNT
Formatted Text: NETWORK SERVICE (or "NT AUTHORITY\NETWORK SERVICE")
Expression: VersionNT=502 (this field is in the "Execution Condition" section)
For more information on the VersionNT property look here:
http://msdn2.microsoft.com/en-us/library/aa370556.aspx
- the second custom action looks like this:

Code: Select all

Property Name: ACCOUNT
Formatted Text: SYSTEM
Expression: VersionNT<>502 (this field is in the "Execution Condition" section)
- in the "Services" page you add your service and in the "User Name" field you set [ACCOUNT]
- you leave the "Password" field empty because these accounts don't have passwords.

Regards,
Cosmin
Last edited by Cosmin on Thu Dec 06, 2007 4:30 pm, edited 1 time in total.
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Uniwares_AS
Posts: 8
Joined: Thu Oct 04, 2007 1:03 am

Works like a charm. Thank you very much.

Although I got a bit confused by the smartedit field for the service account name. After creating the custom actions, I went to change the service settings and entered the name of the property in the field - the smartedit insisted that the property was unknown/missing. Only after leaving the field, ignoring the hint and switching from this page, AI added the property to the list of user defined properties. That behaviour is somewhat confusing. But I guess that is a feature and not a bug and one has to get used to it.
Rawand
Posts: 13
Joined: Tue Apr 08, 2008 2:33 pm

Re: Installing service under different account depending on OS

Hi, I have a same situation here, i want it like that if it was Windows Vista then the service to be installed as Administrator but then we need to have a password , i wonder if its possible?

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

Re: Installing service under different account depending on OS

Hi,

I'm not sure I understand what you mean. Can you please give me more details about this?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Rawand
Posts: 13
Joined: Tue Apr 08, 2008 2:33 pm

Re: Installing service under different account depending on OS

Hi,
What i mean is now in AI there is Service Account username and password while configuring service properties, i want to have this account information entered by user during installation and install the service under that entered account if its possible.
Regards
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Installing service under different account depending on OS

Hi,

This can be done by using properties in the "User Name" and "Password" fields of the Service Properties page. These properties can be set by using a custom dialog like in the Create a new dialog tutorial. Note that instead of "Server Address" and "Port number" your custom dialog will get the username and password of the service.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”