31

I'm using WiX to create an installer for a windows service. It's desirable that the name of service that gets installed and displayed in Services is configurable at install time.

For example, this is what I'm thinking (wix xml snip):

<ServiceInstall 
    Id="MyServiceInstaller" 
    Name="NAME_PASSED_FROM_DIALOG" 
    Type="ownProcess" 
    Start="auto" 
    ErrorControl="normal" 
    Description="My Service" 
    Account="localsystem"/> 

<ServiceControl
    Id="StartMyServiceInstaller" 
    Name="NAME_PASSED_FROM_DIALOG" 
    Start="install"
    Wait="no" />

<ServiceControl
    Id="StopMyServiceInstaller" 
    Name="NAME_PASSED_FROM_DIALOG" 
    Remove="uninstall"
    Stop="both"
    Wait="yes" />

NAME_PASSED_FROM_DIALOG is something I would like to hook up to a custom dialog that gets created and gets displayed to the person installing the service so they can set/modify the service name. I think this is very similar to the WIXUI_INSTALLDIR property that gets set and passed to the WixUI_InstallDir Dialog Set.

My question is:

How do I create a custom UI dialog that can accept user input which gets passed into runtime of the installer?

Scott Saad
  • 17,962
  • 11
  • 63
  • 84

2 Answers2

33

Have fun with UI!

Edit: The original link to answer doesn't exist anymore. FireGiant (the maintainers of Wix) some examples for part of this process, but it's doesn't completely answer this question. There is one further tutorial (UPDATE Aug.2018: Link resurrected from Wayback Machine) that does go most of the way to answer this question.

A high level overview of what will be happening is:

  1. Create a property
  2. Have the UI control set this property
  3. The name attribute on the service will reference the property, ie [ServiceNameProperty].

However this is complex, and the way that is suggested to create a new UI dialog, is to take an existing dialog, make a clone of it, and then edit with new text, controls and use it to populate the property.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Darren Kopp
  • 76,581
  • 9
  • 79
  • 93
  • 11
    Yes and I highly recommend copying an existing dialog that is somewhat like what you want and tweak from there. A lot easier than building from scratch, IMHO. – Rob Mensching Apr 25 '09 at 04:33
  • 2
    Answer's link is dead, after a bit of clicking around site I have found the tutorial here: http://wix.tramontana.co.hu/tutorial/user-interface-revisited – Andy Jan 16 '12 at 00:15
  • 2
    FYI, that tutorial doesn't give an example of how to perform what was mentioned in the answer. It doesn't create a property, doesn't have the UI set the property, and there is no mention of the service that will reference the property. Maybe that literature existed in 2009, but there is nothing in 2016. – sksallaj Oct 26 '16 at 01:47
  • @andy The link is dead. – Sid Sahay Jan 27 '17 at 09:02
10

Try to use WixEdit that is nice tool for creating UI

Andrew Usikov
  • 701
  • 8
  • 13
  • Will definitely have to check this out. :) – Scott Saad Jul 15 '13 at 16:22
  • I had a problem in that enabling a RadioButtonGroup in a dialog seemingly disabled a Text entry field after it. WixEdit allowed me to immediately see that the RadioButtonGroup was invisibly covering the following Text entry field. Many thanks for that info. –  Jul 22 '18 at 12:00
  • There is a great example https://github.com/WixEdit/WixEdit/blob/master/sample/UISample/UISample.wxs – Larytet Nov 07 '18 at 14:34