Solved

Using VB Script to Remove Java v7

Posted on 2013-02-04
8
1,537 Views
Last Modified: 2013-02-14
Hello,

I need a script to remove the Java v7 from all machines on our network through the Group Policy . i searched through the internet and i found to scripts on batch file and the other vb script i need your help to modify the script to remove the java versions on all machines.


The Script Has Two Parts.

1. Batch script executed to kill processes then runs the VB script.
2. VB script uninstalls all versions of JRE then resumes the next step of the batch script

1- Batch Script
@echo off
cd\
cls

@ECHO Version 1.0
@ECHO Uninstall of All JRE Versions And Installation Of JRE6U29

@ECHO Authors: Nainesh Bhavan & Dylan Ogle November 2011

:KillIE&JavaProcesses
echo *** This will kill IE and Java Processes ***
Rem ***
taskkill /F /IM iexplorer.exe
taskkill /F /IM iexplore.exe
taskkill /F /IM javaw.exe
taskkill /F /IM jqs.exe
taskkill /F /IM jusched.exe

:UninstallingOldJREVersions
cd\
cls
echo *** This will uninstall older versions of JRE ***
Rem ***
call cscript %~dp0\JRERemove.vbs

:Backup&ClearRegistryForJavaSoft
start /w regedit /e "%systemroot%\JavaSoftRegBackup.reg" HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft /f

:InstallJREVersion29
cd\
cls
echo *** This installs Java 6 Update 29  ***
Rem ***
ver | find "XP" > nul
if %ERRORLEVEL% == 0 start /w %~dp0\MSJavx86.exe /c:"javatrig.exe /exe_install /l /q /qq" /q:a 

/r:n
%~dp0\jre-6u29-windows-i586-s.exe /s /v"AgreeToLicense=YES IEXPLORER=0 MOZILLA=0 REBOOT=SUPRESS 

JAVAUPDATE=0"

:Copying Configuration Properties Files
cd\
cls
echo *** This creates a backup of current JVM.DLL ini JINIT folders ***
Rem ***
if not exist "C:\Windows\Sun\Java\Deployment" MD "C:\Windows\Sun\Java\Deployment"
copy %~dp0\deployment.config "C:\Windows\Sun\Java\Deployment" /y
copy %~dp0\deployment.properties "C:\Windows\Sun\Java\Deployment" /y

:BackupDLL
cd\
cls
echo *** This creates a backup of current JVM.DLL ini JINIT folders ***
Rem ***
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\hotspot\jvm.dll" ren "C:\Program 

Files\Oracle\JInitiator 1.3.1.18\bin\hotspot\jvm.dll" jvm.dll-old
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.22\bin\hotspot\jvm.dll" ren "C:\Program 

Files\Oracle\JInitiator 1.3.1.22\bin\hotspot\jvm.dll" jvm.dll-old
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.26\bin\hotspot\jvm.dll" ren "C:\Program 

Files\Oracle\JInitiator 1.3.1.26\bin\hotspot\jvm.dll" jvm.dll-old
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.28\bin\hotspot\jvm.dll" ren "C:\Program 

Files\Oracle\JInitiator 1.3.1.28\bin\hotspot\jvm.dll" jvm.dll-old

:CopyDLL
cd\
cls
echo *** Copying JVM.DLL File JINIT Folders ***
Rem ***
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\hotspot\jvm.dll-old" copy %~dp0\Fix

\jvm.dll "C:\Program Files\Oracle\JInitiator 1.3.1.18\bin\hotspot\"
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.22\bin\hotspot\jvm.dll-old" copy %~dp0\Fix

\jvm.dll "C:\Program Files\Oracle\JInitiator 1.3.1.22\bin\hotspot\"
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.26\bin\hotspot\jvm.dll-old" copy %~dp0\Fix

\jvm.dll "C:\Program Files\Oracle\JInitiator 1.3.1.26\bin\hotspot\"
if exist "C:\Program Files\Oracle\JInitiator 1.3.1.28\bin\hotspot\jvm.dll-old" copy %~dp0\Fix

\jvm.dll "C:\Program Files\Oracle\JInitiator 1.3.1.28\bin\hotspot\"

:DisableJavaPlugin
cd\
cls
echo *** This will disable next generation Java Plugin in Control Panel
Rem ***
regedit.exe -s %~dp0\DisableJavaPlugin.reg


:DisableJavaAutoUpdate
cd\
cls
echo *** This will disable next generation Java Plugin in Control Panel
Rem ***
REG.EXE ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v EnableJavaUpdate /t REG_DWORD /d 0 /f
REG.EXE ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v EnableAutoUpdateCheck /t REG_DWORD /d 

0 /f
REG.EXE ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v NotifyDownload /t REG_DWORD /d 0 /f
REG.EXE ADD "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /v NotifyInstall /t REG_DWORD /d 0 /f
REG.EXE DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v SunJavaUpdateSched /f

Open in new window


2- VB Uninstall Script. Simple and Elegant :)

'###########Script Written By Dylan Ogle & Nainesh Bhavan - November 2011##########

'Start Script

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Uninstall Java 2 Runtime Environment, J2SE Runtime Environment
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java 2 Runtime Environment Standard Edition %'")
For Each objSoftware in colJava4dot3
objSoftware.Uninstall()
Next


'Uninstall Java 2 Runtime Environment, J2SE Runtime Environment
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'J2SE Runtime Environment %'")
For Each objSoftware in colJava4dot3
objSoftware.Uninstall()
Next

'Uninstall Java 2 Runtime Environment, SE *
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java 2 Runtime Environment, SE %'")
For Each objSoftware in colJava4dot3
objSoftware.Uninstall()
Next

'Uninstall Java(TM) 6 Update *
Set colJava6dot = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) 6 Update %'")
For Each objSoftware in colJava6dot
objSoftware.Uninstall()
Next

'Uninstall Java(TM) 7 Update *
Set colJava6dot = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) 7 Update %'")
For Each objSoftware in colJava6dot
objSoftware.Uninstall()
Next

'Uninstall Java(TM) 7 *
Set colJava7 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) %'")
For Each objSoftware in colJava7
objSoftware.Uninstall()
Next

Open in new window



Thanks & regards,
0
Comment
Question by:fadyaz
  • 6
  • 2
8 Comments
 
LVL 23

Expert Comment

by:Nagendra Pratap Singh
ID: 38853975
So you want to merge these?
0
 
LVL 2

Author Comment

by:fadyaz
ID: 38853997
Hi npsingh123,

I tried the two scripts and they are not working on my PC , i need a help to let the scripts work or any script to remove java from the PCs .

and if you can help me to let them in one script i appreciate it.
0
 
LVL 23

Expert Comment

by:Nagendra Pratap Singh
ID: 38854016
But your bat file already call the .vbs

call cscript %~dp0\JRERemove.vbs


Does it not work?
0
 
LVL 2

Author Comment

by:fadyaz
ID: 38854171
In which names i should save the files ?? and should they be in same folder ?
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 2

Author Comment

by:fadyaz
ID: 38854363
i made the two files

1- removejava.bat
2- JRERemove.vbs

and i run the removejava.bat abd it called the JRERemove.vbs but the java is still installed on the PC.

Does there is wrong on the files ??
0
 
LVL 2

Author Comment

by:fadyaz
ID: 38854441
I found this script for removing Java 6

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

'Uninstall Java 2 Runtime Environment, J2SE Runtime Environment
Set colJava4dot3 = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java 2 Runtime Environment Standard Edition %'")
For Each objSoftware in colJava4dot3
	objSoftware.Uninstall()
Next

'Uninstall Java(TM) 6 Update *
Set colJava6dot = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) 6 Update %'")
For Each objSoftware in colJava6dot
	WScript.Echo "Found " & objSoftware.Name & " v: " & objSoftware.Version
	objSoftware.Uninstall()
Next 

Open in new window


How i can modify it to remove java 7 ?
0
 
LVL 2

Accepted Solution

by:
fadyaz earned 0 total points
ID: 38872318
I found a perfect VB script that help to remove java and i run it using this comand
cscript /nologo JavaUninstallScript.vbs /keeponly

Open in new window


the VB Script in the Attachment for your information
JavaUninstallScript.txt
0
 
LVL 2

Author Closing Comment

by:fadyaz
ID: 38888365
No body help me in this question. And I searched the internet and i found the attached scrpit and it is working fine and i removed all java on my Organization
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This article will help you understand what HashTables are and how to use them in PowerShell.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

914 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

17 Experts available now in Live!

Get 1:1 Help Now