How to unconfigure TFS vNext Build Agent Service

There may be times when you need to unconfigure, or remove a build agent configured as a service  TFS 2015 and above and there are a few steps missing from the online documentation.

UNCONFIGURE AGENT for TFS 2017 and Above:

Open a command prompt in admin mode and navigate to the folder where the build agent is located and the ConfigureAgent.cmd file exists.

Enter command config.cmd remove

UNCONFIGURE AGENT for TFS 2015:

The steps to configure/unconfigure are located here https://www.visualstudio.com/en-us/docs/build/admin/agents/v1-windows

Open a command prompt in admin mode and navigate to the folder where the build agent is located and the ConfigureAgent.cmd file exists. There is a sub folder called agent and this contains vsoagent.exe, which is used to unconfigure the agent from TFS.

Enter command .\agent\vsoagent.exe /unconfigure

Check the Agent Pools tab in TFS to ensure the build agent is no longer appearing.

REMOVE AGENT WINDOWS SERVICE for TFS 2017:

Ensure the agent is setup to run as a service and is installed

SC QUERY state= all | FIND "VSTS"

image

image

Right click on the service to obtain the Service Name

image

Open a Command Prompt in Admin mode

If the build is running: SC STOP vstsagent.tfs.Dev01

Delete the service

SC DELETE vstsagent.tfs.Dev01

Run the query to make sure the service is now gone:

SC QUERY state= all | FIND "VSTS"

REMOVE AGENT WINDOWS SERVICE for TFS 2015:

There are times when the VSO Agent will not uninstall correctly and a manually removal is required

Open the Services applet to view the list of build services and the name of the service starts with VSO Agent

List of Services

OR

Run the following query from the command line to find the service names: SC QUERY state= all | FIND "VSO"

REMOVE SERVICE:

Right click on the Build Service to remove and select Properties

Highlight the Service Name and right click and select Copy

servicename

Open a Command Prompt in Admin mode

If the build is running: SC STOP vsoagent.localhost.BuildDude

Delete the service

SC DELETE vsoagent.localhost.BuildDude

Run the query to make sure the service is now gone:

SC QUERY state= all | FIND "VSO"

Note: You need to run the command prompt as an administrator, not just logged in as the administrator, but also with administrative rights. If you get errors above about not having the necessary access rights to stop and/or delete the service, run the command prompt as an administrator. You can do this by searching for the command prompt on your start menu and then right-clicking and selecting "Run as administrator".

GENERATE A LIST OF ALL BUILD SERVICES:

If you need to find the short service name of a service, use the following command to generate a text file containing a list of services and their statuses:

SC QUERY state= all | FIND "VSO" >"C:\Service List.txt"

Comments

  • Anonymous
    September 21, 2017
    How to do this for On Premises agent?