MSI Installer throws error, “Verify that you have sufficient privileges to start system services”

The .NET Service

I have been scratching my head for quite some time to try and understand as to why exactly my installation fails with this error.
I created a basic .NET 4.8 windows service that have real basic functionality

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Test
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
#if DEBUG
Service1 test = new Service1();
test.OnDebug();
Thread.Sleep(Timeout.Infinite);
#else
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1()
};
ServiceBase.Run(ServicesToRun);
#endif
}
}
}
</code>
<code>using System; using System.Collections.Generic; using System.Linq; using System.ServiceProcess; using System.Text; using System.Threading; using System.Threading.Tasks; namespace Test { internal static class Program { /// <summary> /// The main entry point for the application. /// </summary> static void Main() { #if DEBUG Service1 test = new Service1(); test.OnDebug(); Thread.Sleep(Timeout.Infinite); #else ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Service1() }; ServiceBase.Run(ServicesToRun); #endif } } } </code>
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Test
{
    internal static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
#if DEBUG
            Service1 test = new Service1();
            test.OnDebug();
            Thread.Sleep(Timeout.Infinite);
#else

            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new Service1()
            };
            ServiceBase.Run(ServicesToRun);
#endif

        }
    }
}
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>using Serilog;
using System;
using System.ServiceProcess;
namespace Test
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
Log.Logger = new LoggerConfiguration()
.WriteTo.File("<Log path>", rollingInterval: RollingInterval.Day)
.MinimumLevel.Information()
.CreateLogger();
}
public void OnDebug()
{
try
{
OnStart(null);
}
catch (Exception ex)
{
Log.Error(ex, ex.Message);
}
}
protected override void OnStart(string[] args)
{
try
{
Log.Information("Service Started");
}
catch (Exception ex)
{
Log.Error(ex, ex.Message);
}
}
protected override void OnStop()
{
try
{
Log.Information("Service Stopped");
}
catch (Exception ex)
{
Log.Error(ex, ex.Message);
}
}
}
}
</code>
<code>using Serilog; using System; using System.ServiceProcess; namespace Test { public partial class Service1 : ServiceBase { public Service1() { InitializeComponent(); Log.Logger = new LoggerConfiguration() .WriteTo.File("<Log path>", rollingInterval: RollingInterval.Day) .MinimumLevel.Information() .CreateLogger(); } public void OnDebug() { try { OnStart(null); } catch (Exception ex) { Log.Error(ex, ex.Message); } } protected override void OnStart(string[] args) { try { Log.Information("Service Started"); } catch (Exception ex) { Log.Error(ex, ex.Message); } } protected override void OnStop() { try { Log.Information("Service Stopped"); } catch (Exception ex) { Log.Error(ex, ex.Message); } } } } </code>
using Serilog;
using System;
using System.ServiceProcess;

namespace Test
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();

            Log.Logger = new LoggerConfiguration()
            .WriteTo.File("<Log path>", rollingInterval: RollingInterval.Day)
            .MinimumLevel.Information()
            .CreateLogger();
        }

        public void OnDebug()
        {
            try
            {
                OnStart(null);
            }
            catch (Exception ex)
            {
                Log.Error(ex, ex.Message);
            }
        }

        protected override void OnStart(string[] args)
        {
            try
            {
                Log.Information("Service Started");
            }
            catch (Exception ex)
            {
                Log.Error(ex, ex.Message);
            }
        }

        protected override void OnStop()
        {
            try
            {
                Log.Information("Service Stopped");
            }
            catch (Exception ex)
            {
                Log.Error(ex, ex.Message);
            }
        }
    }
}

The WIX Project

I created my basic Wix project and added the service as a reference like usual.

Below is the Package.wxs file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><?xml version="1.0" encoding="UTF-8"?>
<?define Name = "Test" ?>
<?define Manufacturer = "Test" ?>
<?define Version = "1.0.0.0" ?>
<?define UpgradeCode = "1D38B1B5-0BD5-419B-9BAC-9F571D2F8048" ?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package
Name="$(Name)"
Manufacturer="$(Manufacturer)"
Version="$(Version)"
UpgradeCode="$(var.UpgradeCode)"
Compressed="yes">
<MajorUpgrade DowngradeErrorMessage="A later version is already installed." />
<Media Cabinet="cab1.cab" Id="1" EmbedCab="yes"></Media>
<Feature Id="Service" Title="Test Service" Level="1">
<ComponentRef Id="ServiceExecutable" />
</Feature>
</Package>
</Wix>
</code>
<code><?xml version="1.0" encoding="UTF-8"?> <?define Name = "Test" ?> <?define Manufacturer = "Test" ?> <?define Version = "1.0.0.0" ?> <?define UpgradeCode = "1D38B1B5-0BD5-419B-9BAC-9F571D2F8048" ?> <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> <Package Name="$(Name)" Manufacturer="$(Manufacturer)" Version="$(Version)" UpgradeCode="$(var.UpgradeCode)" Compressed="yes"> <MajorUpgrade DowngradeErrorMessage="A later version is already installed." /> <Media Cabinet="cab1.cab" Id="1" EmbedCab="yes"></Media> <Feature Id="Service" Title="Test Service" Level="1"> <ComponentRef Id="ServiceExecutable" /> </Feature> </Package> </Wix> </code>
<?xml version="1.0" encoding="UTF-8"?>

<?define Name = "Test" ?>
<?define Manufacturer = "Test" ?>
<?define Version = "1.0.0.0" ?>
<?define UpgradeCode = "1D38B1B5-0BD5-419B-9BAC-9F571D2F8048" ?>

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
    <Package
        Name="$(Name)"
        Manufacturer="$(Manufacturer)"
        Version="$(Version)"
        UpgradeCode="$(var.UpgradeCode)"
        Compressed="yes">

        <MajorUpgrade DowngradeErrorMessage="A later version is already installed." />

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

        <Feature Id="Service" Title="Test Service" Level="1">
            <ComponentRef Id="ServiceExecutable" />
        </Feature>

    </Package>
</Wix>

My Components.wxs file:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><?xml version="1.0" encoding="UTF-8"?>
<?define Name = "Test Service" ?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="Components" Directory="INSTALLFOLDER">
<Component Id="ServiceExecutable" Bitness="always64">
<File Id="Test.exe"
Source="$(var.Test.TargetDir)Test.exe"
KeyPath="true" />
<RemoveFile Id="ALLFILES" Name="*.*" On="both" />
<ServiceInstall Id="ServiceInstaller"
Name="Service1"
Type="ownProcess"
DisplayName="$(Name)"
Description="This is a test service"
Start="disabled"
ErrorControl="normal" />
<ServiceControl Id="StartService"
Name="Service1"
Start="install"
Stop="both"
Remove="uninstall"
Wait="true" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
</code>
<code><?xml version="1.0" encoding="UTF-8"?> <?define Name = "Test Service" ?> <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> <Fragment> <ComponentGroup Id="Components" Directory="INSTALLFOLDER"> <Component Id="ServiceExecutable" Bitness="always64"> <File Id="Test.exe" Source="$(var.Test.TargetDir)Test.exe" KeyPath="true" /> <RemoveFile Id="ALLFILES" Name="*.*" On="both" /> <ServiceInstall Id="ServiceInstaller" Name="Service1" Type="ownProcess" DisplayName="$(Name)" Description="This is a test service" Start="disabled" ErrorControl="normal" /> <ServiceControl Id="StartService" Name="Service1" Start="install" Stop="both" Remove="uninstall" Wait="true" /> </Component> </ComponentGroup> </Fragment> </Wix> </code>
<?xml version="1.0" encoding="UTF-8"?>

<?define Name = "Test Service" ?>

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
    <Fragment>
        <ComponentGroup Id="Components" Directory="INSTALLFOLDER">

            <Component Id="ServiceExecutable" Bitness="always64">

                <File Id="Test.exe"
                      Source="$(var.Test.TargetDir)Test.exe"
                      KeyPath="true" />

                <RemoveFile Id="ALLFILES" Name="*.*" On="both" />

                <ServiceInstall Id="ServiceInstaller"
                                Name="Service1"
                                Type="ownProcess"
                                DisplayName="$(Name)"
                                Description="This is a test service"
                                Start="disabled"
                                ErrorControl="normal" />

                <ServiceControl Id="StartService"
                                Name="Service1"
                                Start="install"
                                Stop="both"
                                Remove="uninstall"
                                Wait="true" />
            </Component>

        </ComponentGroup>
    </Fragment>
</Wix>

And my Folders.wxs file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="INSTALLFOLDER" Name="!(bind.Property.Manufacturer) !(bind.Property.ProductName)" />
</StandardDirectory>
</Fragment>
</Wix>
</code>
<code><Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> <Fragment> <StandardDirectory Id="ProgramFiles6432Folder"> <Directory Id="INSTALLFOLDER" Name="!(bind.Property.Manufacturer) !(bind.Property.ProductName)" /> </StandardDirectory> </Fragment> </Wix> </code>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Fragment>
    <StandardDirectory Id="ProgramFiles6432Folder">
      <Directory Id="INSTALLFOLDER" Name="!(bind.Property.Manufacturer) !(bind.Property.ProductName)" />
    </StandardDirectory>
  </Fragment>
</Wix>

When installing my service without the Service Control the service gets installed correctly and runs fine, however this makes the installer pretty useless since I don’t have the functionality of the installer.

The error only appears to be happening when I run it with the Service Control added.
I troubleshooted a bit with the log file and couldn’t see anything out of the ordinary.
I ran the .msi file with PowerShell as admin and still came across this issue

I appended the Account attribute to the Service Install, that also didn’t seem to make a difference.

I followed steps to add the account to the service group policies, but with no luck, still the same error. (See link below for steps I took)
https://www.blackfog.com/knowledge-base/privileges-to-install-system-services/

At this stage I am ready to give up.
Any help would be greatly appreciated

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật