Java check previous version

Topics: Publishing Issue
May 21, 2015 at 1:08 PM
Edited May 21, 2015 at 4:02 PM
Hi,

I'm actually looking to update Java on the client.
I noticed if Java is not installed, the folder C:\Program Files\Java don't exist, same thing for the registry key HKLM/SOFTWARE/JavaSoft/Java Runtime Environment/CurrentVersion

I want to test the presence before to install a new version on the client. I want to do one of this tests:
  • check if the folder exist (is it possible with the rule file exist ? this do not work for me...)
  • check if the registry key (is there an issue if the link contains spaces ? ("Java Runtime Environement")
If you have another method to check if Java is installed, do not hesitate to share it =)

Best regards

Flo17

Edit :
I think I found the solution for the rules, I have to test it.

Other problem, I did not found the solution to run Powershell script

My Powershell code :
date >> C:\test.txt
$app = Get-WmiObject -Class Win32_Product | Where-Object {
    $_.Name -match "Java"
} | Where-Object { !($_.Name -match "Development")} 

foreach ($a in $app) {$a.Uninstall()}
My 3 tests :
test4
<CustomUpdate>
<Action>
<ElementType>CustomUpdateElements.ScriptElement</ElementType>
<ScriptType>Powershell</ScriptType>
<Filename>.\uninstallJRE.ps1</Filename>
<Arguments></Arguments>
<KillProcess>True</KillProcess>
<TimeBeforeKilling>10</TimeBeforeKilling>
<Variable/>
</Action>
</CustomUpdate>
test5
<CustomUpdate>
<Action>
<ElementType>CustomUpdateElements.ScriptElement</ElementType>
<ScriptType>Powershell</ScriptType>
<Filename>%windir%\System32\WindowsPowerShell\v1.0\powershell.exe</Filename>
<Arguments>-File uninstallJRE.ps1</Arguments>
<KillProcess>True</KillProcess>
<TimeBeforeKilling>10</TimeBeforeKilling>
<Variable/>
</Action>
</CustomUpdate>
test6
<CustomUpdate>
<Action>
<ElementType>CustomUpdateElements.ExecutableElement</ElementType>
<PathToExecutable>%windir%\System32\WindowsPowerShell\v1.0\powershell.exe</PathToExecutable>
<Parameters>-File uninstallJRE.ps1</Parameters>
<KillProcess>True</KillProcess>
<TimeBeforeKilling>10</TimeBeforeKilling>
<Variable/>
</Action>
</CustomUpdate>
Any idea why it does not work?
Coordinator
May 21, 2015 at 7:20 PM
How is set the ExecutionPolicy ?
Get-ExecutionPolicy
Marked as answer by flo17 on 5/22/2015 at 12:39 AM
Editor
May 21, 2015 at 8:45 PM
If you understand a little german, you can read this HowTo: http://www.wsus.de/chrome_per_wpp
May 22, 2015 at 7:45 AM
WinfriedSonntag wrote:
If you understand a little german, you can read this HowTo: http://www.wsus.de/chrome_per_wpp
Thank you for the links.
I thought about this rules but we install java in the default folder. The problem is that Java installe each version in separate folders.
I have to discuss if we change the default folder installation for all the clients or not. We actually works with different java versions.