Sign in to follow this  
Followers 0
blackbeltsmith

noob needs help with java uninstaller

3 posts in this topic

hello all,

I am trying to write a script that will uninstall  Java 7 Update 60 and all earlier versions.  This is the script:

ProcessClose ("iexplorer.exe")
ProcessClose ("iexplore.exe")
ProcessClose ("HUD3.exe")
ProcessClose ("firefox.exe")
ProcessClose ("chrome.exe")
ProcessClose ("jusched.exe")
ProcessClose ("jp21launcher.exe")
ProcessClose ("java.exe")
ProcessClose ("javaw.exe")
ProcessClose ("jqs.exe")

Run(@ComSpec & " /c " & "wmic product where ""name like 'Java%'"" call uninstall", "", @SW_HIDE)

The problem is when I run it on a system with Java 7 Update 55 and Java 7 Update 60 installed I get the following error:

"There was a problem starting C:Program Files(x86)javajre7bininstaller.dll....The specified module could not be found."

I tried to add a ProcessClose function in order to bypass it but it remains open until I manually close it and then I have to rerun the script in order to uninstall the other versions of Java.  I need to run this through SCCM2012 and from my test so far it pauses until a user clicks the OK button.  Can anyone help me with this I have a deadline that is speedly approaching.  Thanks.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Sorry for ressurect this old post, I'm was banging my head agaist a wall unti I finally suceceed.

Maybe it could be of any help for someone else.

#RequireAdmin

_Singleton(@ScriptName)

;close Java if running
;Will return the PID or 0 if the process isn't found.

Local $iexplorePID = ProcessExists("iexplore.exe")
If $iexplorePID Then ProcessClose($iexplorePID)

Local $firefoxPID = ProcessExists("firefox.exe")
If $firefoxPID Then ProcessClose($firefoxPID)

Local $chromePID = ProcessExists("chrome.exe")
If $chromePID Then ProcessClose($chromePID)

Local $juschedPID = ProcessExists("jusched.exe")
If $juschedPID Then ProcessClose($juschedPID)

Local $jp2launcherPID = ProcessExists("jp2launcher.exe")
If $jp2launcherPID Then ProcessClose($jp2launcherPID)

Local $javaPID = ProcessExists("java.exe")
If $javaPID Then ProcessClose($javaPID)

Local $javawPID = ProcessExists("javaw.exe")
If $javawPID Then ProcessClose($javawPID)

Local $jqsPID = ProcessExists("jqs.exe")
If $jqsPID Then ProcessClose($jqsPID)

;uninstall old verson

RunWait (@ComSpec & " /c " & "START /WAIT /MIN WMIC product where ""Name LIKE '%%J2SE Runtime%%'"" call uninstall /nointeractive",  "", "", "")

RunWait (@ComSpec & " /c " & "START /WAIT /MIN WMIC product where ""Name LIKE '%%Java%%'"" call uninstall /nointeractive",  "", "", "")

RunWait (@ComSpec & " /c " & "START /WAIT /MIN WMIC product where ""Name LIKE 'Java(TM) 6%%'"" call uninstall /nointeractive",  "", "", "")

RunWait (@ComSpec & " /c " & "START /WAIT /MIN WMIC product where ""Name LIKE 'Java 7%%'"" call uninstall /nointeractive",  "", "", "")

RunWait (@ComSpec & " /c " & "START /WAIT /MIN WMIC product where ""Name LIKE 'Java 8%%'"" call uninstall /nointeractive",  "", "", "")

;todo review msgbox

MsgBox(64, "Java", "Java uninstalled")

Exit
Edited by revertex

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You can use >_UninstallList to list all Java versions matching the versions that you want, and then run the uninstall command :

#include <UninstallList.au3>

; Lists all keys matching a Java version 7U60 to later
Local $aJavaList = _UninstallList("DisplayName", "(?i)Java 7 Update [6-9]\d+|Java ([89]|1\d+) Update \d+", "UnInstallString", 3)
If NOT IsArray($aJavaList) Then Exit MsgBox(48, "", "Java 7 Update 60 and later not detected")
For $i = 1 To $aJavaList[0][0]
    If NOT StringInStr($aJavaList[$i][4], "msiexec") = 1 Then ContinueLoop ; not an msi installation
    $sUninstallString = StringReplace( $aJavaList[$i][4], "/i", "/X") & " /qb"  ; or qn for a silent uninstall
    ; ConsoleWrite($sUninstallString)
    RunWait($sUninstallString, @SystemDir)
Next
Edited by jguinch

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0