Edit 2014-02-02: With JavaRE 7u51, Ask toolbar now installs into a subfolder named "AskPartnerNetwork" instead of "Ask.com". One could have suspicions about what the point of that is... Meanwhile, @Danilo Roascio's registry values are still obeyed and works just as well as before.
This just highlights that the simple registry fix, is still the simplest and best solution. In case the Java installer changes, so that this registry value is ignored, the following script can still be used as a workaround - just make sure the Ask Toolbar path is updated.
The simplest way to prevent Ask Toolbar from being installed again I could think of, was to create the folder Ask Toolbar installs into and modify the permissions, so no one can write to it.
First, make sure that the Ask Toolbar has been removed. Then copy the following code to Notepad, save it as a .cmd file and run it in an elevated command prompt:
REM Detect processor architecture
set proc_arch=x64
if "%PROCESSOR_ARCHITECTURE%" == "x86" (
if not defined PROCESSOR_ARCHITEW6432 set proc_arch=x86
)
REM Define Ask Toolbar path
if "%proc_arch%" == "x86" set AskPath=%ProgramFiles%\Ask.com
if "%proc_arch%" == "x64" set AskPath=%ProgramFiles(x86)%\Ask.com
set AskReadme=%AskPath%\..\Ask.com_ReadMe.txt
set AskRevert=%AskPath%\..\Ask.com_RestorePermissions.cmd
REM Create dummy Ask Toolbar folder
md "%AskPath%"
REM Add explanatory text file, as to why the dummy folder is there
echo The 'Ask.com' folder is has been created and write protected,> "%AskReadme%"
echo in order to prevent Ask.com Toolbar from being 'accidentally'>> "%AskReadme%"
echo installed, e.g. by Java.>> "%AskPath%\readme.txt">> "%AskReadme%"
echo.>> "%AskReadme%"
echo This has been done using ICACLS by denying write access to the>> "%AskReadme%"
echo EVERYONE security group.>> "%AskReadme%"
echo.>> "%AskReadme%"
echo To revert permissions run:>> "%AskReadme%"
echo %AskRevert%>> "%AskReadme%"
REM Create script to remove restrictions
echo icacls "%AskPath%" /remove:d *S-1-1-0> "%AskRevert%"
REM Deny everyone (SID: S-1-1-0) write access
icacls "%AskPath%" /deny *S-1-1-0:(OI)(CI)W
Please note: ICACLS is included in Windows Vista and later. You can download ICACLS for Windows XP/Server 2003 through Microsoft KB919240, or an updated version through KB943043 (but the latter must first be requested, after which you will receive a link by e-mail to download it). For this purpose, both versions should work equally well.
I have verified with the installer for Java 1.7 update 13, that the Ask Toolbar indeed does not install, even if I leave the checkbox checked.
A similar approach can most likely be used to block most other kinds of piggybacking crapware.
Edit #1
Windows Explorer quirk: Access denied
Windows Explorer behaves a little strange if you try to open the folder. Even though you still have read access to the folder, Windows Explorer will tell you that access is denied, even though only write access has been denied.
This doesn't happen if you simply only have been assigned read access in the first place, but it seems to happen when you have been assigned read/write permission to the folder and then been denied write access.
Reverting permissions
The script has been updated to add a 'read me' text file and a script for removing the restriction again. Both are stored in the 32-bit program files folder.