Build agent logged in as another user losing path

I have a Windows build agent and need to change the account that the agent runs under for various reasons.
Changing the account and running the agent is fine. However, certain steps that make use of commands (acutally executables in c:\windows\system32) fail as the path to command can't be found.
I have tried setting the path explicitly in the user's own environment variables as well as in the to no avail.

An example of the errors I am getting is:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3717, 9): error MSB3073: The command "xcopy  C:\TeamCity\buildAgent\work\a3c8e0f76491c232yadayada.dll C:\TeamCity\buildAgent\work\a3c8e0f76491c232\yadayadadir\ /I /Y
xcopy  C:\TeamCity\buildAgent\work\a3c8e0f76491c232\yadayada.dll C:\TeamCity\buildAgent\work\a3c8e0f76491c232\AppEngine\yadayadadir\ /I /Y" exited with code 9009.

Also, Powershell scripts that are running in other build configurations are failling where I make reference to net.exe and whoami.exe (and indeed anything else that is typically in the system path)

Is there a known issue with respect to running agents in different user accounts or is there something that I have fundamentally missed?

Thanks in advance.

Comment actions Permalink

Hi Steve

The error means that the xcopy executable was found and started successfully, but the tool itself failed.
Probably new user account doesn't have enough permissions on \TeamCity\buildAgent\work\ directory.
Please check Necessary OS and environment permissions.

Whoami tool is a bit different. What's the error there?


Comment actions Permalink

Hi Michael,

Thanks for this.
The issue that I reported along with the other Powershell related problems have been resolved by running the build agent uning the console as opposed to as a service.
The console is logged in as the same user as the service account that had been causing issues.

Your KB cites running in console mode as a workaround though doesn't disclose what underlying issues this mode of operation addresses.
I'm not entirely sure what the differences are under the hood with the service vs console approach but for now I am able to run builds as per my intentions.

If you are able to shed any light on this then I would be most grateful.
For now, however, I'll mark this as answered as I have overcome my initial issues via some means.

Many thanks,


Please sign in to leave a comment.