[wix-users] How to keep service account same on upgrade

Bevan Weiss bevan.weiss at gmail.com
Tue Jul 12 23:22:54 PDT 2022


I've just recently tried this with TopShelf, and I'd recommend not using
Topshelf if you're going to be using a proper installer to control your
service.
Just go back to writing a pure service executable, and installing and
configuring with Wix.

If you're calling the 'install' command on your executable, then it will be
creating a service based upon the configuration that is specified within
your code.
This will obviously overwrite whatever service configuration was put in
place by the end user.

If you really want the service account to persist across repairs / upgrades
etc (and you're using a pure wix solution) then you will need to use Wix to
retrieve it from the registry, and populate it back again..
It would be under HKLM\SYSTEM\CurrentControlSet\Services\{ServiceNameHere}
I don't believe this would work for custom username\password entries
however, unsure how their information (password) is stored in the
registry.  But then you probably shouldn't be using those anymore.. you
should use Virtual Service Accounts, Managed Service Accounts / Group
Managed Service Accounts.


Regards,
Bevan Weiss


On Wed, 13 Jul 2022 at 15:26, raj pandit via wix-users <
wix-users at lists.wixtoolset.org> wrote:

> Hi guys,
>
> I have an application which actually using Topself to be hosted as window
> service. We have wix installer with script based custom action to install
> the service.
>
> <CustomAction Id="RunTopShelfServiceInstall" Directory="INSTALLFOLDER"
> Execute="deferred" Return="ignore" Impersonate="no"
> ExeCommand="[INSTALLFOLDER]management.exe install" />
>
>   <CustomAction Id="RunTopShelfServiceUninstall" Directory="INSTALLFOLDER"
> Execute="deferred" Return="ignore" Impersonate="no"
> ExeCommand="[INSTALLFOLDER] management .exe uninstall" />
>
> I am facing 2 issues that needs solution/approach:
> *1. When we upgrade the existing msi and any issues occurred in the new
> updated version, neither application is in the working condition. *
> * Solution tried: *
>  - understood its because of major upgrades, as it first uninstall the
> previous version and then install the new one. If new upgrades has issue,
> it can not roll back. So, i tried below
> <MajorUpgrade *Schedule="afterInstallExecuteAgain"*
> DowngradeErrorMessage="A newer version of [ProductName] is already
> installed." AllowDowngrades="no" AllowSameVersionUpgrades="yes" />
> * Problem with this solution:*  When error occurs in updated version, It
> also removes the services from the service.msc. Its show correctly in
> Add/Remove program list.
>
> *2. When we change the service account for the service and upgrade to new
> version, it changes the service account or install a new application with
> the local system service account.*
>  - *how to achieve this *?
>  - i followed stack overflow link : here
> <
> https://stackoverflow.com/questions/26985402/updating-a-package-with-a-windows-service-resets-services-account-and-password
> >
> .
> but it does not fit better as we use topself for the hosting application.
> - Please suggest if we can check/retrieve the service account username
> password with c# code and custom action
>
>
> Please let me know if any suggestion.
>
> Thanks,
>
> Rajeev Pandit
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/
>



More information about the wix-users mailing list