# Error reinstalling ElasticSearch with msi

**URL:** <https://discuss.elastic.co/t/error-reinstalling-elasticsearch-with-msi/191531>\
**Category:** Elasticsearch\
**Created:** [July 21, 2019, 5:38pm UTC](https://discuss.elastic.co/t/error-reinstalling-elasticsearch-with-msi/191531 "2019-07-21T17:38:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![GustavoAngelo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavoangelo/32/50604_2.png) [@GustavoAngelo](https://discuss.elastic.co/u/GustavoAngelo)\
**Post date:** [July 21, 2019, 5:38pm UTC](https://discuss.elastic.co/t/error-reinstalling-elasticsearch-with-msi/191531/1 "2019-07-21T17:38:55Z")

</div>

Hi,

I uninstalled ES 7.2.0 for installing in other partition of my drive. When i try to reinstall, it pop-ups this error:

An ES\_HOME environment variable exist but no previous installation was detected. The MSI does not support upgrading from a previous zip based deploy.

I tried to search the ES\_HOME variable environment but didn't find it. I removed the ElasticSearch service manually.

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [July 22, 2019, 6:01am UTC](https://discuss.elastic.co/t/error-reinstalling-elasticsearch-with-msi/191531/2 "2019-07-22T06:01:23Z")

</div>

> [@GustavoAngelo](#):
>
> I removed the Elasticsearch service manually.

Did you [uninstall Elasticsearch 7.2.0 from the system](https://www.elastic.co/guide/en/elasticsearch/reference/current/windows.html#uninstall-msi-gui), as well as removing the service?

---

<div class="post-metadata">

**Author:** ![GustavoAngelo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavoangelo/32/50604_2.png) [@GustavoAngelo](https://discuss.elastic.co/u/GustavoAngelo)\
**Post date:** [July 22, 2019, 1:21pm UTC](https://discuss.elastic.co/t/error-reinstalling-elasticsearch-with-msi/191531/3 "2019-07-22T13:21:16Z")

</div>

Yes, as you can see, there's no elastic in any of the windows.

 ![2019-07-22%2010_17_14-Services](https://us1.discourse-cdn.com/elastic/original/3X/6/e/6ed1ecb71b0897a455817955b25954248aff6ef7.png) ![2019-07-22%2010_16_42-Settings](https://us1.discourse-cdn.com/elastic/original/3X/e/d/ed6693e4d67515437e01780269c424396de6e464.jpeg)

I tried uninstall now with the command line as the link you indicated, the log output:

```
MSI (s) (C0:9C) [10:20:09:420]: Product: Elasticsearch 7.2.0 -- Installation failed.

MSI (s) (C0:9C) [10:20:09:420]: Windows Installer installed the product. Product Name: Elasticsearch 7.2.0. Product Version: 7.2.0. Product Language: 1033. Manufacturer: Elastic. Installation success or error status: 1605.

This action is only valid for products that are currently installed.
C:\Users\gusta\Downloads\elasticsearch-7.2.0.msi
```

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [July 22, 2019, 1:32pm UTC](https://discuss.elastic.co/t/error-reinstalling-elasticsearch-with-msi/191531/4 "2019-07-22T13:32:59Z")

</div>

What does the following show in a new PowerShell terminal

```auto
$env:ES_HOME

```

or

```auto
[System.Environment]::GetEnvironmentVariable("ES_HOME", "Machine")

```

It might also be worth killing any `msiexec.exe` processes running, before trying again

```auto
taskkill /f /im msiexec.exe

```

---

<div class="post-metadata">

**Author:** ![GustavoAngelo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gustavoangelo/32/50604_2.png) [@GustavoAngelo](https://discuss.elastic.co/u/GustavoAngelo)\
**Post date:** [July 22, 2019, 2:00pm UTC](https://discuss.elastic.co/t/error-reinstalling-elasticsearch-with-msi/191531/5 "2019-07-22T14:00:50Z")

</div>

`$env:ES_HOME`

returns

`C:\Program Files\Elastic\Elasticsearch\7.2.0\`  
But this folder doesn't exist

`[System.Environment]::GetEnvironmentVariable("ES_HOME", "Machine")`  
Returns nothing

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [July 23, 2019, 12:42am UTC](https://discuss.elastic.co/t/error-reinstalling-elasticsearch-with-msi/191531/6 "2019-07-23T00:42:50Z")

</div>

> [@GustavoAngelo](#):
>
> `$env:ES_HOME`
> 
> returns
> 
> `C:\Program Files\Elastic\Elasticsearch\7.2.0\`

OK, so there's an `ES_HOME` environment variable specified, but it's not a system environment variable, so it's either a user environment variable or a process environment variable. Both of these can be removed with the following PowerShell

```powershell
foreach ($scope in @("User", "Process")) {
    [System.Environment]::SetEnvironmentVariable("ES_HOME", "", $scope)
}

```

Note that these changes won't be reflected in the current terminal until environment variables are refreshed from the registry. The easier way to check is to open a new terminal and check that `ES_HOME` environment variable no longer exists with

```powershell
$env:ES_HOME

```

which should now not print anything. You can now try the install again. You _may_ optionally also want to remove the `data`, `config` and `logs` directories from the previous installation, if you want to start completely clean. The default location for these is `%ProgramData%\Elastic\Elasticsearch` if using cmd, or `$env:ProgramData\Elastic\Elasticsearch` if using PowerShell.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 20, 2019, 12:42am UTC](https://discuss.elastic.co/t/error-reinstalling-elasticsearch-with-msi/191531/7 "2019-08-20T00:42:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
