Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install and start a Windows Service using WiX

I tried to use the codes below in Wix.

But when installing, the installer was freezing for like 3 minutes on status: Starting services, then I got this message "Service Jobservice failed to start. Verify that you have sufficient privileges to start system services". Is there any wrong in my codes? And can I ask the user to input the windows system user name and password during the installation to get the "privileges"?

Thanks a lot!

    <File Id='JobServiceEXE' Name='JobService.exe' DiskId='1'         Source='JobService.exe' Vital='yes' KeyPath='yes'/>              <ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes"         Name="JobService" DisplayName="123 Co. JobService"         Description="Monitoring and management Jobs" Start="auto"         Account="LocalSystem" ErrorControl="ignore" Interactive="no" />     <ServiceControl Id="StartService"  Stop="both" Remove="uninstall"         Name="JobService" Wait="yes" /> </Component> 
like image 261
Ray Avatar asked Dec 21 '09 19:12

Ray


People also ask

How do I start Windows service after installation?

We can start the Windows Service automatically after installation by making use of the AfterInstall event handler which triggers immediately after Windows Service is installed. You will need to open the ProjectInstaller class and override the AfterInstall event handler and add the code to start the Windows Service.

How do I create a setup project for Windows service in Visual Studio 2019?

Create Setup Project for Window Service Open a dialog box, go to left pane under Installed Templates > Other Project Types > Setup and Deployment > Visual Studio Installer and go to the right pane and select the project as a “Setup Project” and click on the OK button.


1 Answers

The following code works for me... no need to prompt for username/password :)

    <File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' Source='JobService.exe'  KeyPath='yes'/>              <ServiceInstall       Id="ServiceInstaller"       Type="ownProcess"       Name="JobService"       DisplayName="123 Co. JobService"       Description="Monitoring and management Jobs"       Start="auto"       Account="[SERVICEACCOUNT]"       Password="[SERVICEPASSWORD]"       ErrorControl="normal"       />       <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="JobService" Wait="yes" />     </Component> 
like image 107
saschabeaumont Avatar answered Oct 20 '22 14:10

saschabeaumont