title: Topshelf throwing error while installing Windows service
body: <p>When I am trying to install a windows service getting error as below.
  I have verified that the user account has permission to Log on as a service.
  Also I am running the installation by logging in as the same user.
  Running command </p>
  
  <pre><code>'C:\HostedApps2\Apps\ExceptionDefinition\ABC.Cloud.AMAM.ExDefinition.Api.exe install -e "Development" -u "eeur1@ABC.com" -p "GussMaPs"'
  </code></pre>
  
  <p>Exception is this</p>
  
  <pre><code>The transacted install has completed.
  fail: Topshelf.HostFactory[0]
        The service terminated abnormally
  System.InvalidOperationException: The installation failed, and the rollback has been performed. ---&gt; System.Component
  el.Win32Exception: Access is denied
     at System.ServiceProcess.ServiceInstaller.Install(IDictionary stateSaver)
     at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
     at Topshelf.Runtime.Windows.HostInstaller.Install(IDictionary stateSaver)
     at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
     at System.Configuration.Install.TransactedInstaller.Install(IDictionary savedState)
     --- End of inner exception stack trace ---
     at System.Configuration.Install.TransactedInstaller.Install(IDictionary savedState)
     at Topshelf.StartParameters.SpWindowsHostEnvironment.InstallService(InstallHostSettings settings, Action`1 beforeI
  all, Action afterInstall, Action beforeRollback, Action afterRollback)
     at Topshelf.Hosts.InstallHost.Run()
     at Topshelf.HostFactory.Run(Action`1 configureCallback)
  ------- End Executable Output -------
  </code></pre>
  
  <blockquote>
    <p>Things I have verified:
    1. The user account has permission to log on as a service.
    2. Used perfmon tool to identify the error but there is no result with Access denied.</p>
  </blockquote>
  
  <p><strong>The suspect we have is that the user name we are using to install the service belongs to a different domain than that of the PC where we are trying to install the service.</strong></p>