How to UNINSTALL j2re-1_4_2_06-windows-i586-p.exe programmatically

How to UNINSTALL j2re-1_4_2_06-windows-i586-p.exe programmatically?

I want my uninstall program to be able to remove JRE programmatically.

How can I launch uninstall for JRE?

My install program install JRE in a subdirectory of the application.

E:\CFSConnect\j2re-1_4_2_06-windows-i586-p.exe /S /v"/qn INSTALLDIR=E:\CFSConnect\jre REBOOT=Suppress JAVAUPDATE=0"

I want my unistall program to be able to remove the above installed path.
LVL 30
AxterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
try:

E:\CFSConnect\j2re-1_4_2_06-windows-i586-p.exe /s /v /qn /x
0
AxterAuthor Commented:
But I want to make sure it only uninstalls the JRE installed in the path I installed it in.

In other words, if another JRE is installed in c:\Program Files\Java\~~~~~,
I want to make sure my uninstall command does not try to uninstall that path.

How can I make sure the right JRE is uninstalled?
0
objectsCommented:
Are you using the same installer to install the same jre in different places?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

AxterAuthor Commented:
I just tried the command, and nothing happens.

Not even an error message.
0
AxterAuthor Commented:
>>Are you using the same installer to install the same jre in different places?

No.  My concern is that there may be a JRE already installed on the computer when my application runs the setup.
If my application gets uninstalled, I don't want to uninstall a JRE that may have been previously installed or installed after my application has been installed.
0
objectsCommented:
try:

E:\CFSConnect\j2re-1_4_2_06-windows-i586-p.exe /s /v "/qn INSTALLDIR=E:\CFSConnect\jre REBOOT=Suppress" /x
0
AxterAuthor Commented:
Nothing happens with above command either.
0
AxterAuthor Commented:
Seems the only way I can uninstall the JRE is via the following command line:
msiexec.exe /qn /x {7148F0A8-6813-11D6-A77B-00B0D0142060}

However, this does not do a specific path.
0
objectsCommented:
did you try specify the path using the INSTALLDIR property

INSTALLDIR=E:\CFSConnect\jre

And did you try running the earlier command not in silent mode to see whats happening
0
AxterAuthor Commented:
>>did you try specify the path using the INSTALLDIR property

For the msiexec.exe, or for j2re-1_4_2_06-windows-i586-p.exe command????

>>And did you try running the earlier command not in silent mode to see whats happening
No.

I'll see if I can test it out tomorrow.
0
objectsCommented:
>>>did you try specify the path using the INSTALLDIR property

>For the msiexec.exe, or for j2re-1_4_2_06-windows-i586-p.exe command????

msiexec
0
jprgnCommented:
This link will solve your problem

http://www.appdeploy.com/articles/msi_kix/index3.asp

Here's the code

;===========================================
; JRE Install/Uninstall Script
;===========================================
 
$Version = "1.2"
 
If InStr($EXECmdLine,"uninstall")
      $UninstallCommand = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\JRE 1.2.2","UninstallString")
      If $UninstallCommand <> ""
            ? "Uninstalling JRE v" + $Version + "..."
            Shell $UninstallCommand + " -a"
      Else
            $ = LogEvent(1, 1605, "JRE was not found for uninstall","","KiXtart")
            GoTo End
      EndIf
Else
      If ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment", "CurrentVersion") = $Version
            $ = LogEvent(2, 4949, "JRE v" + $Version + " was already installed.","","KiXtart")            
            GoTo End
      Else
            $IEPath = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IE Setup\Setup","Path")
            If Exist(ExpandEnvironmentVars($IEPath) + "\iexplore.exe") $Plugins = "-iexplorer " EndIf
            $NS6ver = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Netscape\Netscape 6","CurrentVersion")
            $NSPath = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Netscape\Netscape 6\" + $NS6Ver + "\Main","Install Directory")
            If Exist("$NSPath") $Plugins = $Plugins + "-netscape6 " EndIf                  
            ? "Installing JRE v" + $Version + "..."
            ? "Plugin switches used: " + $PlugIns ?
            Shell '\\server\package_share\jre\jre-1_2_2_011-win.exe -s -a ' + $PlugIns + '-s -SMS -f1"\\server\package_share\jre\setup.iss"'
            $ = LogEvent(2, 4949, "JRE v" + $Version + " installation complete: " + @SERROR,"","KiXtart")
            Del "C:\Documents and Settings\All Users.WINNT\Start Menu\Programs\Java Plug-in Control Panel .lnk"
            $ = WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\JRE 1.2.2","DisplayName","","REG_SZ")
      EndIf
EndIf

:End
Exit
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AxterAuthor Commented:
After running some test, I found out the install program will not install twice.
So if there is already another JRE if the samve version installed on the target machine, the setup will not reinstall JRE.

That means all I basically have to do is check the registry to see if the current installation is in my application path.
If it is, then I run the uninstall JRE command:
msiexec.exe /qn /x {7148F0A8-6813-11D6-A77B-00B0D0142060}

The registry key I'm using is
SOFTWARE\JavaSoft\Java Runtime Environment\1.4.2_06\JavaHome

Which tells me the path for the JRE version I'm installing.
0
AxterAuthor Commented:
jprgn,
Since your post got me looking in the right direction for the registry keys, I've awared you the points.

Thanks objects for trying.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.