Solved

Java Deployment

Posted on 2015-01-29
4
122 Views
Last Modified: 2015-02-27
Hi all,

I run a predepoyment task to remove old versions of Java and then deploy the new version as msi
@ECHO OFF
cls
TITLE Uninstalling Java 5-8 and Java fx. . .

wmic product where "name like 'Java 7%%'" call uninstall /nointeractive
wmic product where "name like 'Java 8%%'" call uninstall /nointeractive
wmic product where "name like 'JavaFX%%'" call uninstall /nointeractive
wmic product where "name like 'Java(TM) 7%%'" call uninstall /nointeractive
wmic product where "name like 'Java(tm) 6%%'" call uninstall /nointeractive
wmic product where "name like 'Java(TM) 8%%'" call uninstall /nointeractive
wmic product where "name like 'J2SE Runtime Environment%%'" call uninstall /nointeractive
goto END

:END
exit

Works OK, but on some PC's the computer reboots...not good when the user is engaged with work :)

Anyway to suppress reboots in wmic?
0
Comment
Question by:kwatt562
  • 2
4 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 40578741
Hi, you cannot get the Win32_Product class to uninstall with reboot suppression, as it doesn't support any switches.  There can be issues with enumerating the Win32_Product class anyway, so I'd stay away from it.

You would be better to enumerate the registry for any installations of Java, and run their associated UninstallString commands, to which you can add /qn /norestart switches.

The following is a VBS script that you can use to do this.

Regards,

Rob.

On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd /c TASKKILL /IM Java2.exe", 0, True
arrKeys = Array("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall")
Set objRegistry = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\.\root\default:StdRegProv")
For Each strKey In arrKeys
	objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
	If Not IsNull(arrSubKeys) Then
		For Each strSubKey In arrSubKeys
			objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
			objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
			objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "UninstallString", strUninstallString
			If (InStr(1, strDisplayName, "Java", vbTextCompare) Or InStr(1, strDisplayName, "J2SE", vbTextCompare)) And Trim(strUninstallString) <> "" Then
				objShell.Run "cmd /c start /wait ""Java Uninstall"" " & Replace(strUninstallString, "/I", "/X") & " /qn /norestart", 0, True
			End If
			strDisplayName = vbEmpty
			strDisplayVersion = vbEmpty
			strUninstallString = vbEmpty
		Next
	End If
Next

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 40578787
Oh, note that the above script only enumerates the Wow6432Node of the registry, and so only uninstalls 32 bit software.  To search for 64 bit software, remove the Wow6432Node key from that string.

Rob.
0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 40635759
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now