Accessing mapped drive from agent running as windows service


I have to build projects that contain absolute paths with a mapped drive, for example J:\Assemblies\... I read that a lot of people has this need as well and I didn't found a satisfactory solution.

I know that it's better use UNC paths but I don't have the choice because build files (msbuild format) are generated with absolute paths by the IDE.

I created the mapped drive pointing to a local folder by mapping J: to

I changed the user account of the agent from Local system account to my user account with administrator privileges. However it doesn't see the mapped drive.

I also tried to run agent.bat, and in this case the agent sees the mapped drive.

I'm struggling with this problem and I don't know if there is a solution apart to run the service manually.

I think that if I can create the mapped drive before the agent is started automatically as a service, the mapping will be recognized.

Do you know if we can for example start the window service from a batch file that first creates the mapping (subst command), then starts the agent as a service ? This could resolve the problem.

Otherwise, has anyone a solution or a workaround to this problem ?

Comment actions Permalink

Sorry for long the delay. The question is still actual with latest TeamCity release?

Kind regards,


Comment actions Permalink

Yes, it is still an issue with the latest v6 release. I just ran into this problem. So running the agent.bat from the console makes it work - but it's not a very nice solution

Comment actions Permalink

I could suggest you to add this action as first build step within build configuration.


Comment actions Permalink

Ok, running the batch file to map the drives as first build steps seems to do the trick.


Please sign in to leave a comment.