Search code examples
azure-devopswindows-10azure-pipelinesazure-devops-self-hosted-agent

Azure devops interactive agent as admin


I have a Windows 10 Enterprise VM running an Azure Devops Agent in Interactive mode. The agent runs using the only user the machine has, and it is an Administrator with UAC disabled. However, when executing tasks that require an elevated command prompt, as registering dlls, the command fails with the following error message:

##[error]Cmd.exe exited with code '5'.

And this message is when I'm trying to COPY files into Windows\SysWow64

##[error]Error: Failed cp: cp: copyFileSync: could not write to dest file (code=EPERM):C:\windows\SysWow64\test.txt

My testes also fail with the following error message:

Test method TestesRegressaoPGB.Autenticacao.AutenticarNoPGBL02 threw exception:
System.AggregateException: One or more errors occurred. (The requested operation requires elevation.) ---> System.ComponentModel.Win32Exception: The requested operation requires elevation.
TestCleanup method TestesRegressaoPGB.Autenticacao.Cleanup threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..

How do I run all commands while elevated?


Solution

  • I just added permissions on each and every folder the pipeline agent needed to open. As I said to Vito, the agent was not running using a service account.