Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows agent uninstall #4827

Closed
Cody7172 opened this issue May 30, 2024 · 3 comments
Closed

Windows agent uninstall #4827

Cody7172 opened this issue May 30, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Cody7172
Copy link

The very first time I try, I received the following error:

C:\Program Files\Elastic\Agent>elastic-agent.exe uninstall -f
Error: yaml: line 6: did not find expected key
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.10/fleet-troubleshooting.html

I didn’t bother to figure it out and decided to delete folder according to the guide to which I was given a link in the cmd (stop services and delete the entire folder)
So when trying to install the new agent, the following error appears:

Elastic Agent installed but currently broken: service exist but installation path is missing
[...]
"Failed to install service (Elastic Agent): service Elastic Agent already exists.

So now I still unable to install/reinstall or delete agent
"sc stop ElasticAgent", "sc delete ElasticAgent" commands stops service but do not delete it
I don’t delete service through the registry because a reboot is still will be required, but this is prod env
I also tried the --force commands on install and uninstall, but without success.
How can I remove the service or force the agent to reinstall properly?

@Cody7172 Cody7172 added the bug Something isn't working label May 30, 2024
@pierrehilbert
Copy link
Contributor

Hello,
Is it a standalone Agent?
It seems that you have an error in your yaml file that needs to be first fixed.

If this is managed agent, I would advice to change the policy to remove every integrations and that should make the situation better.

@Cody7172
Copy link
Author

Cody7172 commented May 30, 2024

Hello

Hello! Thank you for your response

Is it a standalone Agent? It seems that you have an error in your yaml file that needs to be first fixed.

It's not. I already delete the Agent directory, but Agent service is still on this machine

If this is managed agent, I would advice to change the policy to remove every integrations and that should make the situation

Not possible. It's already offline

@Cody7172
Copy link
Author

Cody7172 commented May 30, 2024

Solved the problem this way:
Go to regedit (admin):

HKEY_LOCAL_MACHINE / SYSTEM / CurrentControlSet / Services

Delete Agent and Endpoint branches

Then close the services window if it is open (it blocks the removal of the service)
Then in admin cmd execute:

sc delete "Elastic Agent"
sc delete "Elastic Endpoint"

You should get a message that such services do not exist.
Now you can install the agent and it installs properly, no reboot required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants