7

I've got a windows service that should run under a domain account specified by the user during installation.

How is this possible with a Wix installer (i.e. ask the user for a account + password that the service should be using)?

Background

My service needs access to a network share and LocalSystem doesn't have the appropriate rights so I want to use an existing domain user account.

nabulke
  • 11,025
  • 13
  • 65
  • 114

1 Answers1

8

ServiceInstall element is your friend here. It contains the attributes Account and Password. So, author a couple of controls on your dialog:

<Control Type="Edit" Property="ACCOUNT" ... />
<Control Type="Edit" Property="PASSWORD" Password="Yes" ... />

And use these properties to instruct ServiceInstall:

<ServiceInstall Id="..." Account="[ACCOUNT]" Password="[PASSWORD]" Type="ownProcess" ... />

Hope this helps.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
  • I think I see what you mean: I have to add my own custom dialog to the installer which asks the user for a account + password. I can use those values in the `ServiceInstall` element to set up an account. Correct? There is no standard, ready-made dialog I can use? – nabulke Mar 05 '12 at 15:10
  • Correct. No, there's no standard dialog, as far as I know, but it should be quite simple to create it – Yan Sklyarenko Mar 05 '12 at 15:21
  • 1
    Be careful when you set a password for the account. You have to acquire the information on uninstallation, too. See this page: http://msdn.microsoft.com/en-us/library/aa371637%28v=vs.85%29.aspx '[...] after deleting a service that was installed with a user name and password, the installer cannot rollback the service without first using a custom action to get the password [...] The CA acquires the password by prompting the user, reading a property from the database, or reading a file. The custom action must then call ChangeServiceConfig, to supply the password, before reinstalling the service.' – BdN3504 Jan 16 '14 at 12:13