/build/static/layout/Breadcrumb_cap_w.png

Uninstall all version of Java 7 (update 1-11)

I would like to un-install all versions of Java 7 update (1-11) using managed installation on the K1000 and deploying it silently.  Has anyone done this before? Any suggestions would be greatly appreciated.


0 Comments   [ + ] Show comments

Answers (5)

Posted by: c_brock 11 years ago
Third Degree Brown Belt
2

Here is a script that will remove the previous versions of Java and install Java 7 update 11!

http://www.itninja.com/blog/view/kace-install-java-7-update-11-using-a-script-removes-previous-versions

 

Posted by: jdornan 11 years ago
Red Belt
2

Ran across this today. Supposedly removes all version of Java, 

http://singularlabs.com/software/javara/

 


Comments:
  • Thank you for the suggestions but I would like to only remove Java 7 update 1-11... I would like to leave Java 6 on the systems. - rchung 11 years ago
Posted by: jagadeish 11 years ago
Red Belt
2

Why dont you try with upgrade table?

Posted by: tellmehow 11 years ago
Senior Purple Belt
1

Use this script. It will remove existing version of Java available.

 

Option Explicit

 

Dim wshShell, fso, strLogFile, ts, strTempDir, strTempISS, strUnString, tsIn, blFound

Dim strUninstLine, CLSID, search5, search6, search7, strJRE1, strDisplayName, strDisplayVersion

Dim strPublisher, strUninstallString, strJREUninstallString, strJREDisplayName

Dim search1, search2, search3, search4, strJREUninstallStringNEW, ret, strUninstCMD

Dim tsISS, strSetupexe, qVal, strComputername

 

qVal = 0

 

Set wshShell = CreateObject("WScript.Shell") 

Set fso = CreateObject("Scripting.FileSystemObject") 

 

strComputername = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

 

If Not fso.FolderExists("C:\Logs") Then fso.CreateFolder("C:\Logs")

strLogFile = "C:\Logs\Java_Uninstall_" & strComputername & ".log"

Set ts = fso.OpenTextFile(strLogFile, 8, True)

 

ts.WriteLine String(80, "_") 

ts.WriteLine String(80, "¯") 

ts.WriteLine Now() & " - Java Runtime(s) uninstallation"

ts.WriteLine String(80, "_") & vbCrlf

 

'# Generate Registry extracts from 'Uninstall' keys.

PreFlight()

 

'# Kill Java Processes

KillProc()

 

strTempDir = wshShell.ExpandEnvironmentStrings("%temp%")

strTempISS = strTempDir & "\iss" 

strUnString = " -s -a /s /f1" 

Set tsIn = fso.OpenTextFile(strTempDir & "\uninstall.tmp", 1) 

 

If Not fso.FolderExists(strTempISS) Then fso.CreateFolder(strTempISS) 

 

blFound = False

 

Do While Not tsIn.AtEndOfStream

    strUninstLine = tsIn.ReadLine 

    CLSID = Mid(strUninstLine, 73, 38) 

    search5 = Instr(strUninstLine, "JRE 1") 

    search6 = Instr(strUninstLine, "]") 

    If search5 > 0 AND search6 > 0 Then 

        strJRE1 = Replace(Mid(strUninstLine, search5, search6),"]","")  

    End If 

 

    On Error Resume Next

 

    strDisplayName = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\DisplayName") 

    strDisplayVersion = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\DisplayVersion") 

    strPublisher = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\Publisher") 

    strUninstallString = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\UninstallString") 

 

    strJREUninstallString = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & strJRE1 & "\UninstallString") 

    strJREDisplayName = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & strJRE1 & "\DisplayName") 

 

    On Error Goto 0

 

    'Search for presence of Java and Sun in DisplayName and Publisher 

    search1 = Instr(1, strDisplayName, "Java", 1) 

    search2 = Instr(1, strPublisher, "Sun", 1) 

    search3 = Instr(1, strDisplayName, "J2SE", 1) 

    search4 = Instr(1, strUninstallString, "setup.exe", 1)

    search7 = InStr(1, strDisplayName, "Development", 1) + InStr(1, strDisplayName, "Java DB", 1)

 

    If strJREUninstallString <> "" Then

        blFound = True

        '# JRE 1 found

        strJREUninstallStringNEW = Replace(strJREUninstallString," -f"," -s -a /s /f") 

        ts.WriteLine Now() & " - " & strJREDisplayName

        ts.WriteLine Now() & " - Uninstall String sent: " & strJREUninstallStringNEW 

        ret = wshShell.Run(strJREUninstallStringNEW , 0, True)

        ts.WriteLine Now() & " - Return: " & ret

        If ret <> 0 And ret <> 3010 Then qVal = 1

 

    ElseIf search7 = 0 And search1 > 0 Or search3 > 0 And search2 > 0 Then

        blFound = True

        strUninstCMD = "msiexec.exe /x " & CLSID & " /norestart /qn"

 

        If search4 > 0 Then

            '# Old InstallShield setup found

            Set tsISS = fso.OpenTextFile(strTempISS & "\" & CLSID & ".iss", 2, True)

 

            'Create Response file for any Java Version 

            tsISS.WriteLine "[InstallShield Silent]" 

            tsISS.WriteLine "Version=v6.00.000" 

            tsISS.WriteLine "File=Response File" 

            tsISS.WriteLine "[File Transfer]" 

            tsISS.WriteLine "OverwrittenReadOnly=NoToAll" 

            tsISS.WriteLine "[" & CLSID & "-DlgOrder]" 

            tsISS.WriteLine "Dlg0=" & CLSID & "-SprintfBox-0" 

            tsISS.WriteLine "Count=2" 

            tsISS.WriteLine "Dlg1=" & CLSID & "-File Transfer" 

            tsISS.WriteLine "[" & CLSID & "-SprintfBox-0]" 

            tsISS.WriteLine "Result=1" 

            tsISS.WriteLine "[Application]" 

            tsISS.WriteLine "Name=Java 2 Runtime Environment, SE v1.4.0_01"

            tsISS.WriteLine "Version=1.4.0_01"

            tsISS.WriteLine "Company=JavaSoft"

            tsISS.WriteLine "Lang=0009"

            tsISS.WriteLine "[" & CLSID & "-File Transfer]"

            tsISS.WriteLine "SharedFile=YesToAll"

            tsISS.Close

 

            strSetupexe = Left(strUninstallString, search4 + 9) 

            strUninstCMD =  strSetupexe & strUnString & Chr(34) & strTempISS & "\" & CLSID & ".iss" & Chr(34) 

        End If

 

        ts.WriteLine Now() & " - " & strDisplayName & "    - Version: " & strDisplayVersion

        ts.WriteLine Now() & " - Uninstall String sent: " & strUninstCMD

        ret = wshShell.Run(strUninstCMD , 0, True) 

        ts.WriteLine Now() & " - Return: " & ret

        If ret <> 0 And ret <> 3010 Then qVal = 1

    End If 

 

Loop

 

tsIn.Close

 

If Not blFound Then

    ts.WriteLine Now() & " - No Java Runtime versions found installed."

    qVal = 99

End If

 

ts.WriteLine String(80, "_") 

ts.WriteLine String(80, "¯") 

ts.Close

fso.DeleteFolder(strTempISS)

fso.DeleteFile(strTempDir & "\uninstall.tmp")

 

WScript.Quit(qVal)

 

Sub PreFlight()

    '# Creates temp files containing extracts from registry 'Uninstall' keys.

    Dim wshShell, fso, sTemp

    Set wshShell = CreateObject("WScript.Shell")

    Set fso = CreateObject("Scripting.FileSystemObject")

    sTemp = wshShell.ExpandEnvironmentStrings("%temp%")

    wshShell.Run "REGEDIT /E %temp%\registry.tmp HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\windows\currentversion\uninstall", 0, True

    wshShell.Run "cmd /c type %temp%\registry.tmp | find /i ""{"" | find /i ""}]"" > %temp%\uninstall.tmp ", 0, True

    wshShell.Run "cmd /c type %temp%\registry.tmp | find /i ""JRE 1"" >> %temp%\uninstall.tmp ", 0, True

    If Not fso.FileExists(sTemp & "\uninstall.tmp") Then

        ts.WriteLine Now() & " - No input - %temp%\uninstall.tmp Reg extract not created."

        ts.WriteLine String(80, "_") 

        ts.WriteLine String(80, "¯") 

        ts.Close

        WScript.Quit(1)

    End If

End Sub

 

Sub KillProc()

    '# kills jusched.exe and jqs.exe if they are running.  These processes will cause the installer to fail.

    Dim wshShell

    Set wshShell = CreateObject("WScript.Shell")

    wshShell.Run "Taskkill /F /IM jusched.exe /T", 0, True

    wshShell.Run "Taskkill /F /IM jqs.exe /T", 0, True

End Sub


Comments:
  • Thank you for the suggestions but I would like to only remove Java 7 update 1-11... I would like to leave Java 6 on the systems. Let me know if the script above can be edited to only remove Java 7 update 1-11 and leave the existing Java 6 on the systems. - rchung 11 years ago
Posted by: petelanglois 11 years ago
4th Degree Black Belt
1

Run this batch file in a Managed Install for Java 7u11.  Watch out as you will need to build a couple of lables so you can pull all the machines with Java.  Java 7 and Java(TM) 7.

taskkill /F /IM iexplorer.exe
taskkill /F /IM iexplore.exe
taskkill /F /IM firefox.exe
taskkill /F /IM chrome.exe
taskkill /F /IM javaw.exe
taskkill /F /IM jqs.exe
taskkill /F /IM jusched.exe
MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F86417002FF} /qn
MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217007FF} /qn
MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217010FF} /qn
MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217004FF} /qn
MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217003FF} /qn
MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217001FF} /qn
MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217006FF} /qn
MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217000FF} /qn Exit

Comments:
  • I run this anytime when the user is logged off due to the killing of IE - petelanglois 11 years ago
    • Petelangolois what is the exact uninstall key for Java 7 Update 11 next to msiexec.exe /x {?????} /qn - rchung 11 years ago
      • This is the one you want for removing 7u11 {26A24AE4-039D-4CA4-87B4-2F83217011FF} - petelanglois 11 years ago
      • The above script will uninstall any Java 7 and leave all your version 6, 5 etc. - petelanglois 11 years ago
  • Killing these generic processes is not a good practice in production environment.. If you do so, you may get a very nice feedback from the enduser... all the best.. - jagadeish 11 years ago
    • Jagadeish What is upgrade table? - rchung 11 years ago
      • http://msdn.microsoft.com/en-us/library/windows/desktop/aa370579(v=vs.85).aspx - jagadeish 11 years ago
    • I only run this when the user is logged off so there is no risk of disturbing end users. - petelanglois 11 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ