0

I have researched all the web looking for clues about how to achieve this but no luck. I have a WiX installer project in Visual Studio 2013 which install a Windows Service (It doesn't contains UI, just console) and since it's installing a service, a user must be specified and that user's rights will be in effect. The problem is that this user is hard-coded on my .WXS file, and it works on my DEV and QA stacks but the user doesn't exists on prod so the installer doesn't work.

I would like to determine whether WXS files can have environment-specific logins defined in the fashion of config files or if anything like this exists.

I wouldn't like to have 3 Setup projects for each environment.

Here's the current WXS code edited for simplicity:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="Some ID" 
           Name="TestService" 
           Language="1033" 
           Version="1.0.0" 
           Manufacturer="TestManufacturer" 
           UpgradeCode="Some Upgrade Code">

    <Package Compressed="yes"/>

    <Media Id="1" Cabinet="test.cab" EmbedCab="yes"/>

    <Property Id="LOGIN">HARD-CODED USER</Property>
    <Property Id="PASSWORD">HARD-CODED PASSWORD</Property>

    <Directory Name="SourceDir" Id="TARGETDIR">
      <Directory Name="ProgramFilesFolder" Id="ProgramFilesFolder">
        <Directory Name="TestDir" Id="_1">
          <Directory Name="Service.ServiceSub" Id="_2">
            <Component Id="_1" Guid="Some Guid">
              <File Source="$(var.Service.ServiceSub.TargetPath)" />

          <ServiceInstall 
            Id="TestServicee" 
            Name="TestService" 
            DisplayName="Test" 
            Type="ownProcess" 
            Start="auto" 
            ErrorControl="normal" 
            Description="This is a test" 
            Account="[LOGIN]" 
            Password="[PASSWORD]" />
          <ServiceControl Id="StopTestService" Name="TestService" Stop="both" Wait="yes" Remove="uninstall" />
        </Component>
      </Directory>
    </Directory>
  </Directory>
</Directory>

<Feature Id="_1" Level="1">
  <ComponentRef Id="_1"/>
</Feature>

</Product>

Please tell me if something is not clear, I can expand the info. Thanks for your help.

Axel97
  • 13
  • 3
  • Is it at all an option to run as LocalSystem or NetworkService? (regular service accounts) or the newer concept of managed service accounts? [See the appropriate section in this answer](https://stackoverflow.com/a/50375540/129130). And [an alternative](https://stackoverflow.com/a/50778838/129130). Using a custom action and embedded values for user and property in different flavors you could use a different account for each setup version by setting one edition property? (EDITION=UAT / PROD / DEV). User accounts can also be created by the MSI itself. – Stein Åsmul Feb 06 '19 at 14:22

2 Answers2

0

Have you tried to construct some UI screens in your installer flow to accept User/Password input so that you can then assign these values to a Property and use it in your example?

Geoff
  • 81
  • 6
0

Thanks for your comments, I just created 3 .Bat files and installed the services with the msiexec passing the credentials as arguments like this:

msiexec /i SampleServiceSetup.msi LOGIN="sampleUsername" PASSWORD="SamplePassword*"

When I need other credentials, just ask for them in the cmd :)

Axel97
  • 13
  • 3