Adding a new user with the log on as a service security setting
When you develop a Windows service and you want it to start automatically when the computer is turned on, you'll need to run that service as a user that has the Log on as a service security setting. In this recipe, you will learn how to apply this attribute to a new user account that we will create.
Getting ready
To prepare for this recipe, create a new setup project and call it LogonAsServiceInstaller
.
How to do it...
Add the LogonAsService
attribute to the User
element, as outlined in the following steps:
Add
UtilExtension
to the project by right-clicking on the References node in Solution Explorer and going to Add Reference... | WixUtilExtension.dll | Add | OK.Add the
UtilExtension
namespace to theWix
element:<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
Add a
User
element within a component and set itsName
attribute to the name of the new user you'd like...