Solved

Java Deployment

Posted on 2015-01-29
4
119 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
Comment Utility
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
Comment Utility
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
Comment Utility
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Image capture and Deploy method is consist on two phases. In our first phase we capture the image of windows from the PC in which Windows and others softwares are already installed. In second phase we deploy the created image on new PC in which we…
First some basics on Windows 7 Backup.  It has 2 components one is a file based backup which is stored in .zip files each zip is split at around 200 Megabytes and there is the Image Backup which is as the name implies a total image of the partition …
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

763 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

10 Experts available now in Live!

Get 1:1 Help Now