# Find all java uninstall strings

**URL:** <https://forums.powershell.org/t/find-all-java-uninstall-strings/19183>\
**Category:** PowerShell Help\
**Created:** [April 26, 2022, 3:16pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183 "2022-04-26T15:16:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Levio](https://avatars.discourse-cdn.com/v4/letter/l/a8b319/32.png) [@Levio](https://forums.powershell.org/u/Levio)\
**Post date:** [April 26, 2022, 3:16pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183/1 "2022-04-26T15:16:25Z")

</div>

Hello Powershell teams,

I am trying to pull all Java uninstall string from the Registry 32 and 64.

```auto
$Javauninstall = gci “HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall”, “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” | 
foreach { gp $_.PSPath } | 
? { $_ -like “*Java*” -and $_.Publisher -like “*Oracle*” } | 
select UninstallString

```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 26, 2022, 3:25pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183/2 "2022-04-26T15:25:34Z")

</div>

> [@Levio](#):
>
> I am trying to pull all Java uninstall string from the Registry 32 and 64.

And what is your question?

BTW: It would be considered to be polite and good style when you avoid using aliasses. It makes your code easier to read. 😉  
Thanks in advance. 👍🏽  
You may read more about that topic:

> **[GitHub - PoshCode/PowerShellPracticeAndStyle: The Unofficial PowerShell Best...](https://github.com/PoshCode/PowerShellPracticeAndStyle)**
>
> The Unofficial PowerShell Best Practices and Style Guide - GitHub - PoshCode/PowerShellPracticeAndStyle: The Unofficial PowerShell Best Practices and Style Guide

---

<div class="post-metadata">

**Author:** ![Levio](https://avatars.discourse-cdn.com/v4/letter/l/a8b319/32.png) [@Levio](https://forums.powershell.org/u/Levio)\
**Post date:** [April 26, 2022, 4:44pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183/3 "2022-04-26T16:44:11Z")

</div>

Thank you Olaf!  
I was trying to pull the Java uninstall string from the registry to proceed an uninstallation of all Java app.  
I think I figured it out.

```auto
$Javauninstall = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
$uninstalllist = Get-ChildItem -Path $Javauninstall | foreach { gp $_.PSPath } -ErrorAction SilentlyContinue | 
? { $_ -like “*Java*” -and $_.Publisher -like “*Oracle*” } | select UninstallString
if ($uninstalllist) {
$uninstalllist = $uninstalllist.UninstallString -Replace "msiexec.exe", "" -Replace "/I", "" -Replace "/X", ""
$uninstalllist = $uninstalllist.Trim()
Write "Uninstalling Java ..."
start-process "msiexec.exe" -arg "/X $uninstalllist /qn /norestart" -Wait
}

```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 26, 2022, 7:06pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183/4 "2022-04-26T19:06:08Z")

</div>

> [@Levio](#):
>
> I think I figured it out.

… still a lot of room for improvement when it comes to readability and code formatting. But if it works it’s fine. 👍🏽 Well done.

---

<div class="post-metadata">

**Author:** ![Levio](https://avatars.discourse-cdn.com/v4/letter/l/a8b319/32.png) [@Levio](https://forums.powershell.org/u/Levio)\
**Post date:** [April 26, 2022, 8:21pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183/5 "2022-04-26T20:21:06Z")

</div>

That’s true. You are the master, and I can’t imagine how you feel when you see my script formatting. It is a mess. I will try to be better teach!  
Thank you to point that out.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 26, 2022, 8:24pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183/6 "2022-04-26T20:24:47Z")

</div>

> [@Levio](#):
>
> You are the master

No, I’m not. 😉 I’m just to old and lazy to spend my time reading badly formatted code. 😉

> [@Levio](#):
>
> I will try to be better teach!

First of all it makes _ **your** _ life easier and only on top of that it is more polite to the people need to deal with your code. 😉

---

<div class="post-metadata">

**Author:** ![Levio](https://avatars.discourse-cdn.com/v4/letter/l/a8b319/32.png) [@Levio](https://forums.powershell.org/u/Levio)\
**Post date:** [April 26, 2022, 8:36pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183/7 "2022-04-26T20:36:28Z")

</div>

Yes, I see. We don’t do the code for only ourselves. We should put in mind that someone else will use it too. So, it is good to follow a minimum formatting standard so they can understand it easily.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 26, 2022, 8:53pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183/8 "2022-04-26T20:53:47Z")

</div>

That’s what I meant. 👍🏽 👍🏽 And if you review your own code in 6 month or more you are another person as well. 😉 … and I could imagine that you’ll like when your code code is easy to read and to understand and you don’t have to re-think how came to the code you wrote that time ago.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/find-all-java-uninstall-strings/19183/9 "2024-05-16T20:17:59Z")

</div>

Closed on May 16, 2024, 8:17pm UTC


