Installing Java 8.162 & Remove Old Versions scripted

Greetings, new BF user here. I am trying to install Java 9 using BF, calling the exe and config file with an installation string. I keep getting exit code 9009. Can someone take a look at my syntax and point me in the right direction? Thanks!

//**Begin Preparation Marker
// Download all specified files
begin prefetch block
add prefetch item name=27B83F9F26649898A5271DC765C7C0AAB80807F1 sha1=27b83f9f26649898a5271dc765c7c0aab80807f1 size=101317184 url=SWDProtocol://127.0.0.1:52311/Uploads/27B83F9F26649898A5271DC765C7C0AAB80807F1/jre-9.0.4_windows-x64_bin.exe.bfswd sha256=874b71eeb072163d7a07cf03c3c0f7061e24cf739dc926e7f058a8b6b6dc7edf
add prefetch item name=AEF57CC1E79FA88E2449A26132A181AE0662EDAD sha1=aef57cc1e79fa88e2449a26132a181ae0662edad size=44 url=SWDProtocol://127.0.0.1:52311/Uploads/AEF57CC1E79FA88E2449A26132A181AE0662EDAD/java.settings.cfg.bfswd sha256=73f1797d22c50dfa473a843ace13ec17fe6887f9a0e0da08b684e24a01009dcf
end prefetch block

// All SWD files will go into a folder in the clients __BESData folder. This folder gets cleared on every restart.
parameter ā€œbaseFolderā€ = ā€œ__Download/ā€
// Move files into subfolders and unescape file names
move ā€œ__Download/27B83F9F26649898A5271DC765C7C0AAB80807F1ā€ "{parameter ā€œbaseFolderā€}jre-9.0.4_windows-x64_bin.exe"
move ā€œ__Download/AEF57CC1E79FA88E2449A26132A181AE0662EDADā€ ā€œ{parameter ā€œbaseFolderā€}java.settings.cfgā€

// Log setup
parameter ā€œmainSWDLogFolderā€ = "{parent folder of client folder of current site}/__Global/SWDDeployData"
folder create "{parameter ā€œmainSWDLogFolderā€}"
parameter ā€œlogFileā€ = ā€œSWD_DeploymentResults.logā€

//**End Preparation Marker
delete __createfile
parameter ā€œlogFolderā€ = ā€œ{parameter ā€œmainSWDLogFolderā€}ā€
// Run setup process
delete run.bat

// Use .bat to set working directory to packages root, for setup command.
createfile until end
@ECHO OFF
cd "{parameter ā€œbaseFolderā€}"
rem // See comments at the beginning of this action for an explanation of the comment markers.
echo %DATE% %TIME% >> "{parameter ā€œlogFolderā€}{parameter ā€œlogFileā€}"
echo Action ID: {id of active action} >> "{parameter ā€œlogFolderā€}{parameter ā€œlogFileā€}"
rem //**Begin Command Marker
echo Command: wait ā€œjre-9.0.4_windows-x64_bin.exe INSTALLCFG=java.settings.cfgā€ >> "{parameter ā€œlogFolderā€}{parameter ā€œlogFileā€}"
set errorlevel=
ā€œjre-9.0.4_windows-x64_bin.exe INSTALLCFG=java.settings.cfgā€ >> ā€œ{parameter ā€œlogFolderā€}{parameter ā€œlogFileā€}ā€ 2>&1
set SWDExitCode=%errorlevel%
rem //**End Command Marker

echo Return code: %SWDExitCode% >> "{parameter ā€œlogFolderā€}{parameter ā€œlogFileā€}"
echo. >> "{parameter ā€œlogFolderā€}{parameter ā€œlogFileā€}"
exit %SWDExitCode%
end

move __createfile run.bat
// You will not be able to stop or take action on an applicable BigFix Client until your installer completes.
// So ensure no user input is required.
// If your package absolutely must interact with the user, replace ā€˜override waitā€™ with ā€˜override runā€™ and ā€˜waitā€™ with ā€˜runā€™.
override wait
hidden=true
completion=job
wait run.bat

//**Begin Closing Marker
// Get the return code of the previous action.
parameter ā€œreturnCodeā€ = ā€œ{exit code of action}ā€

// Task will now exit.
exit {parameter ā€œreturnCodeā€}
//**End Closing Marker

Have a look at the default fixlets for JRE8 and check whether any of that ā€œmagicā€ still applies.

Under JRE8, the installers did some pretty evil trickery like caching themselves into a user profile folder, which by default doesnā€™t exist for the SYSTEM account in 32- or 64-bit mode (I donā€™t recall which), so the fixlets either precreate or make links to the folder.

In troubleshooting, try using psexec to open a command prompt in SYSTEM context and run your installer manually to see whether the error message is useful. The command is psexec -s cmd.exe. Psexec is available at microsoft.com/sysinternals

If this is a 64-bit JRE, be sure to use
action uses wow64 redirection false
in the actionscript before running the installer.

Thanks, will take a look.

OK kids hereā€™s what it ended up taking to get the job done to my spec. Firstly, I ended up using Java 8.162 offline installer so I could pass installation arguments to it. We had just about every version of java 7 you could imagine out there (plus some variants of JS2E, 6, & 8); I manage about 4400 workstations; they all are responding to this well:

I used Manage Software Distribution to create 4 tasks/actions that I then wrapped in a baseline.

Action 1) BAT file that uses wmic to remove all versions of java. wmic product where ā€œname like ā€˜Java%%%ā€™ā€ call uninstall /nointeractive

Action 2) Powershell file that sweeps the registry for orphaned keys. (modified from spiceworks)

Action 3) Powershell file that sweeps up the file system for orphaned directories. (modified from spiceworks)

Action 4) deliver the new Java version using switches(for use w/ offline installer): INSTALL_SILENT=1 AUTO_UPDATE=0 REMOVEOUTOFDATEJRES=1

Hope that helps; that was rough!

1 Like

Funny enough I just had to do pretty much the same thing this morning. I just created a script to remove all old versions of JRE 8 after installing the 162 update. I made the file myself but used the software distribution wizard to deploy it. Glad it worked out for you.