Service_SetLogonInformations
Description
Section titled “Description”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
Syntax
Section titled “Syntax”Service_SetLogonInformations(sServiceName, sDomain, sUserName, sPassword) As Boolean
Parameters
Section titled “Parameters”sServiceName (String)
Section titled “sServiceName (String)”Name of the service. Use the service name, for example Spooler, not the display name.
sDomain (String)
Section titled “sDomain (String)”Domain of the account. Use . for a local account.
sUserName (String)
Section titled “sUserName (String)”Name of the account that the service logs on as
sPassword (String)
Section titled “sPassword (String)”Password of the account, "*" for a password saved by CapaInstaller, or an empty string for Local System
Return value
Section titled “Return value”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.
Example
Section titled “Example”If bStatus Then bStatus = Service_SetLogonInformations("Capa Agent", ".", "LocalSystem", "")Related functions
Section titled “Related functions”Service_Create Service_SetStartMode Constants Package Property Variables