Skip to content

Service_SetLogonInformations

Sets the account that a Windows service logs on as. The account is set as sDomain\sUserName.

For a local account, use a dot (.) as sDomain. To make the service log on as Local System, use "." as sDomain, "LocalSystem" as sUserName and an empty password, as shown in the example.

The new account is used the next time the service starts. The function doesn’t restart the service.

If you specify "*" as sPassword, CapaInstaller will assume that the password for the specified user has been encrypted by CapaInstaller and saved in registry. The password will then be obtained and decrypted.
This way you can avoid using clear text passwords in the script. See more about the password encryption feature Using passwords in CapaInstaller VB Scripting Library

Service_SetLogonInformations(sServiceName, sDomain, sUserName, sPassword) As Boolean

Name of the service. Use the service name, for example Spooler, not the display name.

Domain of the account. Use . for a local account.

Name of the account that the service logs on as

Password of the account, "*" for a password saved by CapaInstaller, or an empty string for Local System

The function returns False if the service doesn’t exist, or if Windows can’t change the logon account, for example because the user name or password is wrong.

If bStatus Then bStatus = Service_SetLogonInformations("Capa Agent", ".", "LocalSystem", "")

Scripting Guidelines

Service_Create Service_SetStartMode Constants Package Property Variables