How to delete/unregister build agent on TFS 2015

Harrison picture Harrison · Jul 28, 2016 · Viewed 11.7k times · Source

I have set up TFS 2015 with dedicated server to store the build agent. However, when I delete the build agent on TFS 2015 app server, it still show up on build server, in windows "Services"

Now the build server display error because the service exist but not running.

How can a build agent be removed from TFS 2015?

Answer

Legends picture Legends · Jul 29, 2016

Update:

Just execute:

C:\YourAgentFolderPath\agent>agent\vsoagent /unconfigure

Answer from year 2016:

Go to the folder on the Build Server where you have unzipped your build agent.

Some of the commenters mentioned, that they didn't have to delete the settings file, so you can try to skip this step, perhaps it is not necessary anymore.

Delete the settings.json file if it exists.

enter image description here

Open the commandline tool (cmd.exe) with admin rights!
Go to the folder as shown above in the screenshot.
Run the following command:

C:\YourAgentFolderPath\agent>agent\vsoagent /unconfigure

Result (console log):

Removing EventLog source vsoagent.vsalm.YourAgentName.
Service vsoagent.vsalm.YourAgentName is being removed from the system...
Service vsoagent.vsalm.YourAgentName was successfully removed from the system.
Attempt to stop service vsoagent.vsalm.YourAgentName.