Last Updated:

Fix Error 1920: Failed to Start Windows Service in WiX v3.8 Installer (Insufficient Privileges)

If you’ve ever encountered Error 1920: "Failed to start service [ServiceName]. Verify that you have sufficient privileges to start system services" while installing a Windows service using WiX v3.8, you’re not alone. This error typically occurs during the final stages of installation when the WiX installer attempts to start the service but lacks the necessary permissions or configuration to do so.

Windows services require elevated privileges to install and start, and even minor misconfigurations in WiX, service accounts, or security settings can trigger this error. In this blog, we’ll demystify the root causes of Error 1920 and provide step-by-step solutions to resolve it, with a focus on WiX v3.8-specific configurations.

Table of Contents#

  1. Understanding Error 1920
  2. Common Causes of Insufficient Privileges
  3. Step-by-Step Solutions
  4. Verification and Testing
  5. Troubleshooting Tips
  6. References

Understanding Error 1920#

Error 1920 is a Windows Installer (MSI) error code indicating that the installer failed to start a service during installation. Windows services run in the background with system-level privileges, so starting them requires the installer to have elevated access and the service itself to be configured with the right permissions.

In WiX v3.8, this error often stems from:

  • The installer not running with administrative privileges.
  • The service account lacking "Log on as a service" rights or other critical permissions.
  • Misconfigured WiX elements (e.g., missing ServiceInstall or ServiceControl settings).
  • Security restrictions on the service executable.

Common Causes of Insufficient Privileges#

Before diving into fixes, let’s identify the most likely culprits:

CauseDescription
Missing Elevated PrivilegesThe WiX installer isn’t running with administrative rights, preventing it from starting system services.
Incorrect Service AccountThe service is configured to run under an account with insufficient permissions (e.g., a local user without "Log on as a service" rights).
Malconfigured WiX ElementsMissing or misconfigured ServiceInstall (to define the service) or ServiceControl (to start/stop the service) elements in the WiX project.
Service Executable PermissionsThe service’s .exe file lacks read/execute permissions for the service account.
Dependencies or ConflictsThe service depends on another unstarted service, or there’s a port/resource conflict blocking startup.

Step-by-Step Solutions#

Let’s resolve Error 1920 with targeted fixes, starting with the most common issues.

1. Ensure the Installer Runs with Elevated Privileges#

Windows services require administrative privileges to install and start. By default, WiX installers may not prompt for elevation, leading to Error 1920.

Fix:#

Force the installer to run with elevated privileges by setting the InstallPrivileges attribute in the WiX Package element to "elevated". This ensures the installer prompts the user for admin rights during execution.

WiX Code Snippet:

<Package  
  InstallerVersion="200"  
  Compressed="yes"  
  InstallScope="perMachine"  <!-- Services require per-machine installation -->  
  InstallPrivileges="elevated"  <!-- Forces elevation -->  
  />  
  • InstallScope="perMachine": Critical for services, as they are system-wide (not user-specific).
  • InstallPrivileges="elevated": Triggers the User Account Control (UAC) prompt, ensuring the installer runs as admin.

2. Configure the Service Account with Sufficient Permissions#

The service’s runtime account (e.g., LocalSystem, LocalService, or a custom domain account) must have the right to start the service.

Case 1: Using a Built-in Account (e.g., LocalSystem)#

Built-in accounts like LocalSystem have high privileges and are ideal for most services.

WiX Configuration:
In the ServiceInstall element, set Account="LocalSystem" (no password required for built-in accounts):

<ServiceInstall  
  Id="MyServiceInstall"  
  Name="MyService"  <!-- Internal service name (matches ServiceControl) -->  
  DisplayName="My Application Service"  <!-- Name shown in Services.msc -->  
  Type="ownProcess"  <!-- Service runs in its own process -->  
  Start="auto"  <!-- Start automatically on boot -->  
  ErrorControl="normal"  <!-- Log error if startup fails (installer continues) -->  
  Account="LocalSystem"  <!-- Use LocalSystem account -->  
  />  

Case 2: Using a Custom Domain/Local Account#

If using a custom account (e.g., DOMAIN\ServiceAccount), grant it "Log on as a service" rights and configure WiX to pass the credentials.

Step 1: Grant "Log on as a service" Rights

  • Open secpol.msc (Local Security Policy).
  • Navigate to Local Policies > User Rights Assignment > Log on as a service.
  • Add the custom account (e.g., DOMAIN\ServiceAccount) to the list.

Step 2: Configure WiX for Custom Account
Use Account, Password, and ServiceStartName in ServiceInstall (replace [ServiceAccount] and [Password] with your credentials):

<ServiceInstall  
  Id="MyServiceInstall"  
  Name="MyService"  
  DisplayName="My Application Service"  
  Type="ownProcess"  
  Start="auto"  
  ErrorControl="normal"  
  Account="[ServiceAccount]"  <!-- Custom account (e.g., DOMAIN\ServiceAccount) -->  
  Password="[Password]"  <!-- Account password -->  
  ServiceStartName="[ServiceAccount]"  <!-- Required for non-built-in accounts -->  
  />  

Note: For security, avoid hardcoding passwords in WiX. Use WiX variables or pass credentials via command-line parameters during installation.

3. Verify Service Executable Security Settings#

The service’s .exe file must allow the service account to read and execute it.

Fix:#

  1. Locate your service executable (e.g., MyService.exe).
  2. Right-click the file > Properties > Security > Edit.
  3. Click Add and enter the service account (e.g., LocalSystem, DOMAIN\ServiceAccount).
  4. Grant the account Read & execute and Read permissions.
  5. Click Apply to save changes.

4. Correct WiX ServiceInstall and ServiceControl Configuration#

Missing or misconfigured ServiceInstall (to define the service) or ServiceControl (to start the service) elements are frequent WiX pitfalls.

Example: Full WiX Service Configuration#

Here’s a complete WiX snippet to install and start a service, with explanations:

<Component Id="MyServiceComponent" Guid="YOUR-GUID-HERE">  
  <!-- Install the service executable -->  
  <File  
    Id="MyServiceExe"  
    Source="..\Bin\Release\MyService.exe"  <!-- Path to your service EXE -->  
    KeyPath="yes"  <!-- Marks this file as the component's key path -->  
    />  
 
  <!-- Define the service (ServiceInstall) -->  
  <ServiceInstall  
    Id="MyServiceInstall"  
    Name="MyService"  <!-- Internal name (must match ServiceControl) -->  
    DisplayName="My Application Service"  
    Type="ownProcess"  <!-- Service type: ownProcess (separate) or shareProcess -->  
    Start="auto"  <!-- Startup type: auto, manual, disabled, or delayedAuto -->  
    ErrorControl="normal"  <!-- Installer behavior on failure: normal (log), critical (rollback) -->  
    Account="LocalSystem"  <!-- Service account (use LocalSystem for simplicity) -->  
    />  
 
  <!-- Control the service (start/stop during install/uninstall) -->  
  <ServiceControl  
    Id="MyServiceControl"  
    Name="MyService"  <!-- Must match ServiceInstall's Name -->  
    Start="install"  <!-- Start the service during installation -->  
    Stop="both"  <!-- Stop during install (if upgrading) and uninstall -->  
    Remove="uninstall"  <!-- Remove the service during uninstall -->  
    Wait="yes"  <!-- Wait for the service to start/stop before proceeding -->  
    />  
</Component>  

Key Attributes Explained:#

  • ServiceInstall/Name: The internal service name (used by ServiceControl to reference the service).
  • ServiceControl/Start="install": Triggers the installer to start the service after installation. Omit this if you don’t want to start the service during install.
  • Wait="yes": Ensures the installer waits for the service to start/stop, preventing race conditions.

5. Check for Dependencies or Conflicts#

If the service still fails to start, check for underlying issues:

  • Dependencies: Use sc qc [ServiceName] in Command Prompt to list dependencies. Ensure all required services (e.g., EventLog, Tcpip) are running.
  • Event Viewer: Check the System or Application logs (Event Viewer > Windows Logs) for service-specific errors (e.g., "Failed to start due to logon failure" or "Port in use").
  • Port/Resource Conflicts: Use netstat -ano to check for port conflicts if the service uses network resources.

Verification and Testing#

After applying fixes, verify the service starts successfully:

  1. Rebuild the Installer: Rebuild your WiX project to generate a new .msi file.
  2. Run the Installer: Double-click the .msi and follow prompts (UAC will request elevation).
  3. Check Services.msc: Open services.msc and confirm your service is listed with a "Running" status.
  4. Event Viewer: Look for a success message in the System log (e.g., "The [ServiceName] service started successfully").

Troubleshooting Tips#

If Error 1920 persists:

  • Enable WiX Logging: Run the installer with logging to debug:

    msiexec /i "MyInstaller.msi" /l*v "InstallLog.txt"  

    Search InstallLog.txt for "Error 1920" or "ServiceControl" to identify failures.

  • Test the Service Manually: Start the service directly via services.msc to isolate installer-specific issues. If it fails here, the problem is with the service itself (not WiX).

  • Check Service Account Password: For custom accounts, ensure the password in ServiceInstall matches the domain/local account’s password (and hasn’t expired).

References#

By following these steps, you’ll resolve Error 1920 and ensure your WiX v3.8 installer starts the Windows service reliably. Let us know in the comments if you encountered other edge cases!