?
Solved

Using VB Script to Remove Java v7

Posted on 2013-02-04
8
Medium Priority
?
1,573 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 24

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 24

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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 2

Author Comment

by:fadyaz
ID: 38854171
In which names i should save the files ?? and should they be in same folder ?
0
 
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

Need protection from advanced malware attacks?

Look no further than WatchGuard's Total Security Suite, providing defense in depth against today's most headlining attacks like Petya 2.0 and WannaCry. Keep your organization out of the news with protection from known and unknown threats.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
Suggested Courses

765 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