The user account used by the service is required to have sufficient permissions to perform the build and manage the service.
When a TeamCity build agent is installed as a Windows service, there may appear various 'Permission denied' or 'Access denied' errors during the build process, see details below. Agent running as Windows Service Limitations Until TeamCity 2019.2.2 is released, it is recommended to use Java 8u232 version for TeamCity server. TeamCity versions up to 2019.2.1 running under JDK 8u242+ can report : Could not initialize class XXX errors, for example, on Git operations or Windows domain authentication operations. To see issues specific to particular versions of TeamCity, go to the respective section of upgrade notes.
This page contains a list of workarounds for known issues in TeamCity.