# Unable to install new version of agent (fleet managed)

**URL:** <https://discuss.elastic.co/t/unable-to-install-new-version-of-agent-fleet-managed/372742>\
**Category:** Elastic Agent\
**Created:** [January 3, 2025, 10:53am UTC](https://discuss.elastic.co/t/unable-to-install-new-version-of-agent-fleet-managed/372742 "2025-01-03T10:53:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jay29300](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jay29300/32/140445_2.png) [@jay29300](https://discuss.elastic.co/u/jay29300)\
**Post date:** [January 3, 2025, 10:53am UTC](https://discuss.elastic.co/t/unable-to-install-new-version-of-agent-fleet-managed/372742/1 "2025-01-03T10:53:37Z")

</div>

Hello.  
I try to install agent with fleet integration but i don't understand why it doesn't work.

in fleet i have this script:

```auto
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri http://srv-ansible:8088/endpoints/asset-directory/content/elastic/beats/elastic-agent/elastic-agent-8.17.0-windows-x86_64.zip -OutFile elastic-agent-8.17.0-windows-x86_64.zip 
Expand-Archive .\elastic-agent-8.17.0-windows-x86_64.zip -DestinationPath .
cd elastic-agent-8.17.0-windows-x86_64
.\elastic-agent.exe install --url=https://evo-vs-ef01.eveno.fermetures.fr:8220 --enrollment-token=NFRQckpKQUJZNjFmUDNzOUUzSFY6TFlrUEhRdFdRdDZQY1Fyb0JJT0lRUQ== --force --insecure

```

but when i run in PS as admin:  
`[] Uninstall failed [0s] Error: unable to find elastic-agent.exe on path: exec: "elastic-agent.exe": cannot run executable found relative to current directory`

I have already elastic-agent 8.14.1 on this server... i try to stop service before but same result!

And if i try to uninstall manually :

```auto
PS C:\temp\elastic-agent-8.17.0-windows-x86_64> cd 'C:\Program Files\Elastic\Agent\'
PS C:\Program Files\Elastic\Agent> .\elastic-agent.exe uninstall
Elastic Agent will be uninstalled from your system at C:\Program Files\Elastic\Agent. Do you want to continue? [Y/n]:Y
[] Failed to uninstall agent [0s] Error uninstalling. Printing logs
Error: error uninstalling agent: uninstall must be run from outside the installed path 'C:\Program Files\Elastic\Agent'

```

Someone can help me ?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [January 3, 2025, 6:54pm UTC](https://discuss.elastic.co/t/unable-to-install-new-version-of-agent-fleet-managed/372742/2 "2025-01-03T18:54:29Z")

</div>

Hi @jay29300 Welcome to the community!

A couple things

1st) You can upgrade a fleet managed agents from the Fleet UI, that is the correct way not uninstalling and re-installing... That is the correct way

 ![Screenshot 2025-01-03 at 10.51.18 AM](https://us1.discourse-cdn.com/elastic/original/3X/5/8/58389e6475de02696578cb55006d461002ce7bd2.png)

2nd) IF you want to uninstall the Elastic Agent you need to carefully follow the commands

The proper command as shown in the docs is [here](https://www.elastic.co/guide/en/fleet/current/elastic-agent-cmd-options.html#elastic-agent-uninstall-command)

`C:\"Program Files"\Elastic\Agent\elastic-agent.exe uninstall`

if you CD to the directory it will not properly uninstall ...

The way I found to fix this in the past is to re-install the original version of the agent back over... get it running correctly then Upgrade from the UI...
