Why am I getting a permission error for AgentService.exe after Azure agent installation from Agent Pool?

Chris 0 Reputation points
2025-02-28T01:48:50.0066667+00:00

I've currently trying to install an agent from Azure Devops > Project Settings > Agent Pools > Agents. I've set up the machines, and am able to get the agent itself onto the machine, and run them manually. However, I cannot run them as a service because during the installation, I get the following error:

An error occurred trying to start process '"C:\agent\bin\AgentService.exe"' with working directory 'C:\azagent'. Access is denied.

I would really appreciate any help resolving this error.

I have tried several credentials, admin, non-admin, new users, etc. but for some reason, I cannot seem to get past this error. Is there a particular user I'm supposed to use from Azure? Is it an issue with the security settings on my computer? I've even tried testing giving the current user full access to that specific file through the property settings. None of these work. I'm wondering what I did wrong.

I can still run the agent manually via the .\run.cmd command in Powershell, but I cannot start the AgentService.exe in C:\agent\bin\AgentService.exe.

EDIT (Some more details):

PS C:\agent> .\config.cmd
  ___                      ______ _            _ _
 / _ \                     | ___ (_)          | (_)
/ /_\ \_____   _ _ __ ___  | |_/ /_ _ __   ___| |_ _ __   ___  ___
|  _  |_  / | | | '__/ _ \ |  __/| | '_ \ / _ \ | | '_ \ / _ \/ __|
| | | |/ /| |_| | | |  __/ | |   | | |_) |  __/ | | | | |  __/\__ \
\_| |_/___|\__,_|_|  \___| \_|   |_| .__/ \___|_|_|_| |_|\___||___/
                                   | |
        agent v4.251.0             |_|          (commit 69c6517)
>> Connect:
Enter server URL > https://xxx.visualstudio.com
Enter authentication type (press enter for PAT) >
Enter personal access token > ***
Connecting to server ...
>> Register Agent:
Enter agent pool (press enter for default) > TEST-QA1
Enter agent name (press enter for SRVR1) >
Scanning for tool capabilities.
Connecting to the server.
Pool TEST-QA1 already contains an agent with name SRVR1.
Enter replace? (Y/N) (press enter for N) > Y
Successfully replaced the agent
Testing agent connection.
Enter work folder (press enter for _work) >
2025-02-27 21:32:31Z: Settings Saved.
Enter run agent as service? (Y/N) (press enter for N) > y
Enter enable SERVICE_SID_TYPE_UNRESTRICTED for agent service (Y/N) (press enter for N) >
Enter User account to use for the service (press enter for NT AUTHORITY\NETWORK SERVICE) > ******@abc.com
Enter Password for the account SRVR1\******@abc.com > ***
Error reported in diagnostic logs. Please examine the log for more details.
    - C:\agent\_diag\Agent_00000000-000000-utc.log
Granting file permissions to 'SRVR1\******@abc.com'.
An error occurred trying to start process '"C:\agent\bin\AgentService.exe"' with working directory 'C:\agent'. Access is denied.
PS C:\agent>
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,434 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.