Worklet - Java 271

Hey guys, just need some assistance finalising the Java worklet. The automatic patching seems to have uninstalled Java from a fair few machines so need to resolve.

It works fine running from the local machine, however no luck from Automox.

Eval is fine.
It downloads the two files then does not run the commands; installing 2 instances of Java (32 and 64bit).

#Handle Exit Codes:
trap { $host.ui.WriteErrorLine($_.Exception); exit 90 }

try{

    $process1 = Start-Process -FilePath 'jre-8u271-windows-i586.exe' -ArgumentList '/s', 'REMOVEOUTOFDATEJRES=1', '/L C:\ProgramData\amagent\worklets\java\java_86.log' -Wait -Passthru -ErrorAction Stop
    $process2 = Start-Process -FilePath 'jre-8u271-windows-x64.exe' -ArgumentList '/s', '/L C:\ProgramData\amagent\worklets\java\java_64.log' -Wait -Passthru -ErrorAction Stop
    exit 0

}

Catch{

    $Exception = $error[0].Exception.Message + "`nAt Line " + $error[0].InvocationInfo.ScriptLineNumber
    Write-Output $Exception
    exit 90
}

Would appreciate any assistance.

Hey there. I haven’t installed JRE in quite a while. With that being said, it looks like there are now 2 installers (exe and msi), and each has a method to define configurations.
EXE appears to prefer a configuration file: https://docs.oracle.com/javase/8/docs/technotes/guides/install/windows_installer_options.html
MSI supports additional switches and/or a config file:
https://docs.oracle.com/javacomponents/doc/install-guide/use-installer-configuration-file-install-jre.htm#JSMSI-GUID-27F7BF81-6CFD-4533-96AD-F962D22A0DF5

As an Automox best practice, I would suggest using an alternate directory for your log file. the amagent directory is the running directory for the Automox agent, and content may not persist through agent actions, or upgrades. There will be cases where this directory permissions are reset by the agent as well.