We needed to uninstall Java 7 from Machines.For that we created a collection based on product ID instead of Display Name in Add Remove programs.
This collection query will include all machines that have 32-bit or 64-bit Java Installed
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_INSTALLED_SOFTWARE on SMS_G_System_INSTALLED_SOFTWARE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_INSTALLED_SOFTWARE.ProductCode like "{26a24ae4-039d-4ca4-87b4-2f832170%" or SMS_G_System_INSTALLED_SOFTWARE.ProductCode like "{26A24AE4-039D-4CA4-87B4-2F864170%"
We can then uninstall the products using a SCCM
create a package to run this script:
You may need to add more products depending on other versions that you have installed for Java for me we only had java 7 update 3 , 4 7, 9 ,10
strComputer = "."
Set objShell = CreateObject("WScript.Shell")
Set objProducts = CreateObject("Scripting.Dictionary")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Product",,48)
For Each objItem in colItems
objProducts.Add objItem.IdentifyingNumber, objItem.Caption
Next
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217003FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217003FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417003FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417003FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217004FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217004FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417004FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417004FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217007FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217007FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417007FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417007FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217009FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217009FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417009FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417009FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217010FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217103FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417010FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417010FF} /norestart /qn",1,True
End If
If someone wants to uninstall all versions of Java from machines , Please try
http://ivan.dretvic.com/2011/02/who-hates-java-how-to-remove-all-java-installations-on-your-network/
this has a script that can do that. We only tested this script for 32-bit Java and not 64-bit java. It works well.
Hope this helps
This collection query will include all machines that have 32-bit or 64-bit Java Installed
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_INSTALLED_SOFTWARE on SMS_G_System_INSTALLED_SOFTWARE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_INSTALLED_SOFTWARE.ProductCode like "{26a24ae4-039d-4ca4-87b4-2f832170%" or SMS_G_System_INSTALLED_SOFTWARE.ProductCode like "{26A24AE4-039D-4CA4-87B4-2F864170%"
We can then uninstall the products using a SCCM
create a package to run this script:
You may need to add more products depending on other versions that you have installed for Java for me we only had java 7 update 3 , 4 7, 9 ,10
strComputer = "."
Set objShell = CreateObject("WScript.Shell")
Set objProducts = CreateObject("Scripting.Dictionary")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Product",,48)
For Each objItem in colItems
objProducts.Add objItem.IdentifyingNumber, objItem.Caption
Next
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217003FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217003FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417003FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417003FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217004FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217004FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417004FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417004FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217007FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217007FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417007FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417007FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217009FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217009FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417009FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417009FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F83217010FF}") Then
' Uninstall java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F83217103FF} /norestart /qn",1,True
End If
If objProducts.Exists("{26A24AE4-039D-4CA4-87B4-2F86417010FF}") Then
' Uninstall Java
objShell.Run "msiexec /x {26A24AE4-039D-4CA4-87B4-2F86417010FF} /norestart /qn",1,True
End If
If someone wants to uninstall all versions of Java from machines , Please try
http://ivan.dretvic.com/2011/02/who-hates-java-how-to-remove-all-java-installations-on-your-network/
this has a script that can do that. We only tested this script for 32-bit Java and not 64-bit java. It works well.
Hope this helps
Comments
Post a Comment