Vijayendar Gururaja
Vijayendar Gururaja

Reputation: 860

windows powershell command to uninstall all versions of java except a specific version

Windows powershell command to uninstall all versions of Java except a specific version. This command should work in windows 7 & above.

The following command uninstalls all versions. How do I modify the following in such a way that a specific version 8.0.770.3 does not uninstall.

gwmi Win32_Product -filter "name like 'Java%' AND vendor like 'Oracle%' AND (version like '[78].%' OR version like '1.[78].%')" | % { $_.Uninstall() }

Upvotes: 0

Views: 25466

Answers (2)

user13352345
user13352345

Reputation: 11

simplest powershell script

gwmi Win32_Product -filter "name like 'Java%'" | % { $_.Uninstall() }

Upvotes: 0

Martin
Martin

Reputation: 1963

Change the filtering of version.

gwmi Win32_Product -filter "name like 'Java%' AND vendor like 'Oracle%' AND
not version = '8.0.770.3'" | % { $_.Uninstall() }

Upvotes: 1

Related Questions