Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Specified cast is not valid" on jre8 upgrade #18

Closed
guillaume-ferry opened this issue Jul 31, 2018 · 15 comments
Closed

"Specified cast is not valid" on jre8 upgrade #18

guillaume-ferry opened this issue Jul 31, 2018 · 15 comments

Comments

@guillaume-ferry
Copy link

Hello,

On some w10 hosts, Specified cast is not valid error message is encoutered when trying to upgrade jre8.
It seems that the Get-ItemProperty command is badly interpreted on these hosts when building $checkreg64 and $checkreg32.
In the Get-ItemProperty documentation, the registry path is prefixed by the 'Registry::' string.
https://docs.microsoft.com/fr-fr/powershell/scripting/getting-started/cookbooks/working-with-registry-entries?view=powershell-5.1

Modified and cpacked this in a new jre8 package solved my problem on many systems. Can you fix it upstream?

Regards,
Guillaume

@proudcanadianeh
Copy link
Owner

proudcanadianeh commented Aug 1, 2018 via email

@ghost
Copy link

ghost commented Aug 26, 2018

https://superuser.com/questions/1352166/how-to-resolve-error-specified-cast-is-not-valid-error-during-installation/

I'm currently receiving this error when installing Java SE Runtime Environment (jre8), updating used to work fine:

Searching if new version exists...
ERROR: Specified cast is not valid.
The install of jre8 was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'.
 See log for details.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - jre8 (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'.
 See log for details.

chocolatey.log:

1124 [DEBUG] - XmlConfiguration is now operational
 1124 [INFO ] - ============================================================
 1124 [INFO ] - Chocolatey v0.10.11
 1124 [DEBUG] - Chocolatey is running on Windows v 10.0.17134.0
 1124 [DEBUG] - Attempting to delete file "c:/programdata/chocolatey/choco.exe.old".
 1124 [DEBUG] - Attempting to delete file "c:\programdata\chocolatey\choco.exe.old".
 1124 [DEBUG] - Command line: "c:\programdata\chocolatey\choco.exe" install jre8
 1124 [DEBUG] - Received arguments: install jre8
 1124 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
 1124 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers...
 1124 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed...
 1124 [DEBUG] - The source 'https://chocolatey.org/api/v2/' evaluated to a 'normal' source type
 1124 [DEBUG] - 
NOTE: Hiding sensitive configuration data! Please double and triple 
 check to be sure no sensitive data is shown, especially if copying 
 output to a gist for review.
 1124 [DEBUG] - Configuration: CommandName='install'|
CacheLocation='C:\Users\user\AppData\Local\Temp\chocolatey'|
ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='https://chocolatey.org/api/v2/'|SourceType='normal'|
Debug='False'|Verbose='False'|Trace='False'|Force='False'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='True'|AcceptLicense='False'|
AllowUnofficialBuild='False'|Input='jre8'|AllVersions='False'|
SkipPackageInstallProvider='False'|PackageNames='jre8'|
Prerelease='False'|ForceX86='False'|OverrideArguments='False'|
NotSilent='False'|ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Windows'|
Information.PlatformVersion='10.0.17134.0'|
Information.PlatformName='Windows 10'|
Information.ChocolateyVersion='0.10.11.0'|
Information.ChocolateyProductVersion='0.10.11'|
Information.FullName='choco, Version=0.10.11.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'|

Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='True'|
Information.UserName='user'|Information.UserDomainName='DESKTOP'|
Information.IsUserAdministrator='True'|
Information.IsUserSystemAccount='False'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='True'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'|
Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'|
Features.RemovePackageInformationOnUninstall='False'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='False'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'|
PinCommand.Command='unknown'|OutdatedCommand.IgnorePinned='False'|
Proxy.BypassOnLocal='True'|
 1124 [DEBUG] - _ Chocolatey:ChocolateyInstallCommand - Normal Run Mode _
 1124 [INFO ] - Installing the following packages:
 1124 [INFO ] - jre8
 1124 [INFO ] - By installing you accept licenses for the packages.
 1124 [INFO ] - [NuGet] Installing 'jre8 8.0.181'.
 1124 [DEBUG] - [NuGet] Added file 'chocolateyInstall.ps1' to folder 'jre8\tools'.
 1124 [DEBUG] - [NuGet] Added file 'chocolateyUninstall.ps1' to folder 'jre8\tools'.
 1124 [DEBUG] - [NuGet] Added file 'thisJreInstalled.ps1' to folder 'jre8\tools'.
 1124 [DEBUG] - [NuGet] Added file 'jre8.nuspec' to folder 'jre8'.
 1124 [DEBUG] - [NuGet] Added file 'jre8.nupkg' to folder 'jre8'.
 1124 [INFO ] - [NuGet] Successfully installed 'jre8 8.0.181'.
 1124 [INFO ] - 
jre8 v8.0.181 [Approved]
 1124 [INFO ] - jre8 package files install completed. Performing other installation steps.
 1124 [DEBUG] - Setting installer args for jre8
 1124 [DEBUG] - Setting package parameters for jre8
 1124 [DEBUG] - Contents of 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1':
 1124 [DEBUG] - try {

$arguments = @{}

  # Now we can use the $env:chocolateyPackageParameters inside the Chocolatey package
  $packageParameters = $env:chocolateyPackageParameters

  # Default value
  $exclude = $null

  # Now parse the packageParameters using good old regular expression
  if ($packageParameters) {
      $match_pattern = "\/(?<option>([a-zA-Z0-9]+)):(?<value>([`"'])?([a-zA-Z0-9- \(\)\s_\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
      $option_name = 'option'
      $value_name = 'value'

      if ($packageParameters -match $match_pattern ){
          $results = $packageParameters | Select-String $match_pattern -AllMatches
          $results.matches | % {
            $arguments.Add(
                $_.Groups[$option_name].Value.Trim(),
                $_.Groups[$value_name].Value.Trim())
        }
      }
      else
      {
          Throw "Package Parameters were found but were invalid (REGEX Failure)"
      }

      if($arguments.ContainsKey("exclude")) {
          Write-Host "exclude Argument Found"
          $exclude = $arguments["exclude"]
      }

  } else {
      Write-Debug "No Package Parameters Passed in"
  }

  $scriptDir = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
  
  $packageName = 'jre8'
  # Modify these values -----------------------------------------------------
  # Find download URLs at http://www.java.com/en/download/manual.jsp
  $url = 'https://javadl.oracle.com/webapps/download/AutoDL?BundleId=234472_96a7b8442fe848ef90c96a2fad6ed6d1'
  $checksum32 = '9E5E6A1C5D26D93454751E65486F728233FDAC3B50FF763F6709FB87DD960CE5'
  $url64 = 'https://javadl.oracle.com/webapps/download/AutoDL?BundleId=234474_96a7b8442fe848ef90c96a2fad6ed6d1'
  $checksum64 = 'CD2F756133D59525869ACB605A54EFD132FCD7EAF53E2EC040D92EF40A2EA60A'
  $oldVersion = '8.0.1710.11'
  $version = '8.0.1810.13'
  #--------------------------------------------------------------------------
  $homepath = $version -replace "(\d+\.\d+)\.(\d\d)(.*)",'jre1.$1_$2'
  $installerType = 'exe'
  $installArgs = "/s REBOOT=0 SPONSORS=0 AUTO_UPDATE=0 $32dir"
  $installArgs64 = "/s REBOOT=0 SPONSORS=0 AUTO_UPDATE=0 $64dir"
  $osBitness = Get-ProcessorBits
   
  Write-Output "Searching if new version exists..."
  $checkreg64 = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -like '*Java 8*' -and ([Version]$_.DisplayVersion) -eq $version} -ErrorAction SilentlyContinue
  $checkreg32 = Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -like '*Java 8*' -and ([Version]$_.DisplayVersion) -eq $version} -ErrorAction SilentlyContinue
  

    # Checks if JRE 32/64-bit in the same version is already installed and if the user excluded 32-bit Java.
    # Otherwise it downloads and installs it.
    # This is to avoid unnecessary downloads and 1603 errors.
    if ($checkreg32 -ne $null) 
    {
      Write-Output "Java Runtime Environment $version (32-bit) is already installed. Skipping download and installation"
    } 
    elseif ($exclude -ne "32") 
    {
      Write-Output "Installing JRE $version 32-bit"
      Install-ChocolateyPackage $packageName $installerType $installArgs $url -checksum $checksum32 -checksumtype 'sha256'
    } 
    else 
    {
      Write-Output "Java Runtime Environment $Version (32-bit) excluded for installation"
    }

    # Only check for the 64-bit version if the system is 64-bit

    if ($osBitness -eq 64) 
    {
      if ($checkreg64 -ne $null) 
      {
        Write-Output "Java Runtime Environment $version (64-bit) is already installed. Skipping download and installation"
      } 
      elseif ($exclude -ne "64") 
      {
        Write-Output "Installing JRE $version 64-bit"
        Install-ChocolateyPackage $packageName $installerType $installArgs64 -url64bit $url64 -checksum64 $checksum64 -checksumtype64 'sha256'
      } 
      else 
      {
        Write-Output "Java Runtime Environment $Version (64-bit) excluded for installation"
      }
    }
  
  #Uninstalls the previous version of Java if either version exists
  Write-Output "Searching if the previous version exists..."
  $checkoldreg64 = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, PSChildName | Where-Object { $_.DisplayName -like '*Java 8*' -and ([Version]$_.DisplayVersion) -eq $oldversion} -ErrorAction SilentlyContinue
  $checkoldreg32 = Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, PSChildName | Where-Object { $_.DisplayName -like '*Java 8*' -and ([Version]$_.DisplayVersion) -eq $oldversion} -ErrorAction SilentlyContinue
 
  if($checkoldreg32 -ne $null) 
  {
     Write-Warning "Uninstalling JRE version $oldVersion 32bit"
     $32 = $checkoldreg32.PSChildName
     Start-ChocolateyProcessAsAdmin "/qn /norestart /X$32" -exeToRun "msiexec.exe" -validExitCodes @(0,1605,3010)
  }
  if($checkoldreg64 -ne $null)
  {
     Write-Warning "Uninstalling JRE version $oldVersion $osBitness bit" #Formatted weird because this is used if run on a x86 install
     $64 = $checkoldreg64.PSChildName
     Start-ChocolateyProcessAsAdmin "/qn /norestart /X$64" -exeToRun "msiexec.exe" -validExitCodes @(0,1605,3010)
  }
} catch {
  #Write-ChocolateyFailure $packageName $($_.Exception.Message)
  throw
}

  1124 [INFO ] - The package jre8 wants to run 'chocolateyInstall.ps1'.
  1124 [INFO ] - Note: If you don't run this script, the installation will fail.
  1124 [INFO ] - Note: To confirm automatically next time, use '-y' or consider:
  1124 [INFO ] - choco feature enable -n allowGlobalConfirmation
  1124 [INFO ] - Do you want to run the script?
  1124 [INFO ] -  1) yes
  1124 [INFO ] -  2) no
  1124 [INFO ] -  3) print
  1124 [INFO ] - Choice selected: 'yes'
  1124 [DEBUG] - Calling built-in PowerShell host with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters ''']
  1124 [DEBUG] - Redirecting System.Management.Automation.resources, Version=3.0.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35, requested by ''
  1124 [DEBUG] - Host version is 5.1.17134.1, PowerShell Version is '5.1.17134.228' and CLR Version is '4.0.30319.42000'.
  1124 [INFO ] - VERBOSE: Exporting function 'Format-FileSize'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-ChecksumValid'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyUnzip'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyWebFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariableNames'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-FtpFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-OSArchitectureWidth'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-PackageParameters'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-PackageParametersBuiltIn'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-ToolsLocation'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-UACEnabled'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-VirusCheckValid'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-WebFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-WebFileName'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-WebHeaders'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyDesktopLink'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyEnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyExplorerMenuItem'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyFileAssociation'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyInstallPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPath'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPinnedTaskBarItem'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPowershellCommand'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyShortcut'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyVsixPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyZipPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-Vsix'.
  1124 [INFO ] - VERBOSE: Exporting function 'Set-EnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Exporting function 'Set-PowerShellExitCode'.
  1124 [INFO ] - VERBOSE: Exporting function 'Start-ChocolateyProcessAsAdmin'.
  1124 [INFO ] - VERBOSE: Exporting function 'Test-ProcessAdminRights'.
  1124 [INFO ] - VERBOSE: Exporting function 'Uninstall-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyEnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyZipPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Update-SessionEnvironment'.
  1124 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateyFailure'.
  1124 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateySuccess'.
  1124 [INFO ] - VERBOSE: Exporting function 'Write-FileUpdateLog'.
  1124 [INFO ] - VERBOSE: Exporting function 'Write-FunctionCallLogMessage'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Get-ProcessorBits'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Get-OSBitness'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Get-InstallRegistryKey'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Generate-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Add-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Start-ChocolateyProcess'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Invoke-ChocolateyProcess'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Remove-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting alias 'refreshenv'.
  1124 [DEBUG] - Loading community extensions
  1124 [DEBUG] - Importing 'C:\ProgramData\chocolatey\extensions\chocolatey-core\chocolatey-core.psm1'
  1124 [INFO ] - VERBOSE: Loading module from path 'C:\ProgramData\chocolatey\extensions\chocolatey-core\chocolatey-core.psm1'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-AppInstallLocation'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-AvailableDriveLetter'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-EffectiveProxy'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-PackageCacheLocation'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-PackageParameters'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-WebContent'.
  1124 [INFO ] - VERBOSE: Exporting function 'Register-Application'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-AppInstallLocation'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-AvailableDriveLetter'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-EffectiveProxy'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-PackageCacheLocation'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-PackageParameters'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-UninstallRegistryKey'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-WebContent'.
  1124 [INFO ] - VERBOSE: Importing function 'Register-Application'.
  1124 [DEBUG] - Importing 'C:\ProgramData\chocolatey\extensions\chocolatey-windowsupdate\chocolatey-windowsupdate.psm1'
  1124 [INFO ] - VERBOSE: Loading module from path 'C:\ProgramData\chocolatey\extensions\chocolatey-windowsupdate\chocolatey-windowsupdate.psm1'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-WindowsUpdate'.
  1124 [INFO ] - VERBOSE: Exporting function 'Test-WindowsUpdate'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-WindowsUpdate'.
  1124 [INFO ] - VERBOSE: Importing function 'Test-WindowsUpdate'.
  1124 [INFO ] - VERBOSE: Exporting function 'Format-FileSize'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-ChecksumValid'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyUnzip'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyWebFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariableNames'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-FtpFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-OSArchitectureWidth'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-PackageParameters'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-PackageParametersBuiltIn'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-ToolsLocation'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-UACEnabled'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-VirusCheckValid'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-WebFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-WebFileName'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-WebHeaders'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyDesktopLink'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyEnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyExplorerMenuItem'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyFileAssociation'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyInstallPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPath'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPinnedTaskBarItem'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPowershellCommand'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyShortcut'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyVsixPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyZipPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-Vsix'.
  1124 [INFO ] - VERBOSE: Exporting function 'Set-EnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Exporting function 'Set-PowerShellExitCode'.
  1124 [INFO ] - VERBOSE: Exporting function 'Start-ChocolateyProcessAsAdmin'.
  1124 [INFO ] - VERBOSE: Exporting function 'Test-ProcessAdminRights'.
  1124 [INFO ] - VERBOSE: Exporting function 'Uninstall-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyEnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyZipPackage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Update-SessionEnvironment'.
  1124 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateyFailure'.
  1124 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateySuccess'.
  1124 [INFO ] - VERBOSE: Exporting function 'Write-FileUpdateLog'.
  1124 [INFO ] - VERBOSE: Exporting function 'Write-FunctionCallLogMessage'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-AppInstallLocation'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-AvailableDriveLetter'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-EffectiveProxy'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-PackageCacheLocation'.
  1124 [INFO ] - VERBOSE: Exporting function 'Get-WebContent'.
  1124 [INFO ] - VERBOSE: Exporting function 'Register-Application'.
  1124 [INFO ] - VERBOSE: Exporting function 'Install-WindowsUpdate'.
  1124 [INFO ] - VERBOSE: Exporting function 'Test-WindowsUpdate'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Get-ProcessorBits'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Get-OSBitness'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Get-InstallRegistryKey'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Generate-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Add-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Start-ChocolateyProcess'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Invoke-ChocolateyProcess'.
  1124 [INFO ] - VERBOSE: Exporting alias 'Remove-BinFile'.
  1124 [INFO ] - VERBOSE: Exporting alias 'refreshenv'.
  1124 [INFO ] - VERBOSE: Importing function 'Format-FileSize'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-AppInstallLocation'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-AvailableDriveLetter'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-ChecksumValid'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-ChocolateyUnzip'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-ChocolateyWebFile'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-EffectiveProxy'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-EnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-EnvironmentVariableNames'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-FtpFile'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-OSArchitectureWidth'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-PackageCacheLocation'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-PackageParameters'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-PackageParametersBuiltIn'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-ToolsLocation'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-UACEnabled'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-UninstallRegistryKey'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-VirusCheckValid'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-WebContent'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-WebFile'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-WebFileName'.
  1124 [INFO ] - VERBOSE: Importing function 'Get-WebHeaders'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-BinFile'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyDesktopLink'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyEnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyExplorerMenuItem'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyFileAssociation'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyInstallPackage'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPackage'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPath'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPinnedTaskBarItem'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPowershellCommand'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyShortcut'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyVsixPackage'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyZipPackage'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-Vsix'.
  1124 [INFO ] - VERBOSE: Importing function 'Install-WindowsUpdate'.
  1124 [INFO ] - VERBOSE: Importing function 'Register-Application'.
  1124 [INFO ] - VERBOSE: Importing function 'Set-EnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Importing function 'Set-PowerShellExitCode'.
  1124 [INFO ] - VERBOSE: Importing function 'Start-ChocolateyProcessAsAdmin'.
  1124 [INFO ] - VERBOSE: Importing function 'Test-ProcessAdminRights'.
  1124 [INFO ] - VERBOSE: Importing function 'Test-WindowsUpdate'.
  1124 [INFO ] - VERBOSE: Importing function 'Uninstall-BinFile'.
  1124 [INFO ] - VERBOSE: Importing function 'Uninstall-ChocolateyEnvironmentVariable'.
  1124 [INFO ] - VERBOSE: Importing function 'Uninstall-ChocolateyPackage'.
  1124 [INFO ] - VERBOSE: Importing function 'Uninstall-ChocolateyZipPackage'.
  1124 [INFO ] - VERBOSE: Importing function 'Update-SessionEnvironment'.
  1124 [INFO ] - VERBOSE: Importing function 'Write-ChocolateyFailure'.
  1124 [INFO ] - VERBOSE: Importing function 'Write-ChocolateySuccess'.
  1124 [INFO ] - VERBOSE: Importing function 'Write-FileUpdateLog'.
  1124 [INFO ] - VERBOSE: Importing function 'Write-FunctionCallLogMessage'.
  1124 [INFO ] - VERBOSE: Importing alias 'Add-BinFile'.
  1124 [INFO ] - VERBOSE: Importing alias 'Generate-BinFile'.
  1124 [INFO ] - VERBOSE: Importing alias 'Get-InstallRegistryKey'.
  1124 [INFO ] - VERBOSE: Importing alias 'Get-OSBitness'.
  1124 [INFO ] - VERBOSE: Importing alias 'Get-ProcessorBits'.
  1124 [INFO ] - VERBOSE: Importing alias 'Invoke-ChocolateyProcess'.
  1124 [INFO ] - VERBOSE: Importing alias 'refreshenv'.
  1124 [INFO ] - VERBOSE: Importing alias 'Remove-BinFile'.
  1124 [INFO ] - VERBOSE: Importing alias 'Start-ChocolateyProcess'.
  1124 [DEBUG] - Running 'ChocolateyScriptRunner' for jre8 v8.0.181 with packageScript 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1', packageFolder:'C:\ProgramData\chocolatey\lib\jre8', installArguments: '', packageParameters: '',
  1124 [DEBUG] - Running 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'
  1124 [DEBUG] - No Package Parameters Passed in
  1124 [DEBUG] - Running Get-ProcessorBits 
  1124 [INFO ] - Searching if new version exists...
  1124 [ERROR] - ERROR: Specified cast is not valid.
  1124 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters '''] exited with '-1'.
  1124 [DEBUG] - Calling command ['"C:\WINDOWS\System32\shutdown.exe" /a']
  1124 [DEBUG] - Command ['"C:\WINDOWS\System32\shutdown.exe" /a'] exited with '1116'
  1124 [DEBUG] - Capturing package files in 'C:\ProgramData\chocolatey\lib\jre8'
  1124 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\jre8.nupkg'
  with checksum '0B5EDF39443CCB6991A28E7B8798B499'
  1124 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\jre8.nuspec'
  with checksum 'CFEA3240CB37E74A003B46853472DCB1'
  1124 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'
  with checksum 'E83845E0C10018AF33580ABC480E415F'
  1124 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyUninstall.ps1'
  with checksum '4B7A4D65C739871EBC12A4D89EE2C603'
  1124 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\tools\thisJreInstalled.ps1'
  with checksum '11582402A4211505F6F5B024C7EBCEED'
  1124 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.arguments".
  1124 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.extra".
  1124 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.version".
  1124 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.sxs".
  1124 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.pin".
  1124 [DEBUG] - Attempting to delete directory "C:\ProgramData\chocolatey\lib-bad\jre8".
  1124 [DEBUG] - Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers...
  1124 [ERROR] - The install of jre8 was NOT successful.
  1124 [ERROR] - Error while running 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'.
 See log for details.
  1124 [DEBUG] - Moving 'C:\ProgramData\chocolatey\lib\jre8'
 to 'C:\ProgramData\chocolatey\lib-bad\jre8'
  1124 [DEBUG] - Attempting to delete file "C:\Users\user\AppData\Local\NuGet\Cache\jre8.8.0.181.nupkg".
  1124 [WARN ] - 
Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
  1124 [INFO ] - 
  1124 [ERROR] - Failures
  1124 [ERROR] -  - jre8 (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'.
 See log for details.
  1124 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
  1124 [DEBUG] - Exiting with -1`

@proudcanadianeh
Copy link
Owner

Thanks for the additional info. My best guess at this point is that there is an issue in the registry on affected computers, but I haven't been able to replicate it on my end. Any chance you could try running those commands manually and see if it specifies the key its having issues with?

@ghost
Copy link

ghost commented Aug 26, 2018

@proudcanadianeh I get an error when running the commands given in the answer:

checkreg64 : The term 'checkreg64' is not recognized as the name of a cmdlet, function, script file, or operable progra
m. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ checkreg64 = Get-ItemProperty HKLM:\Software\Microsoft\Windows\Curren ...
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (checkreg64:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

@proudcanadianeh
Copy link
Owner

Remove the checkreg64 variable from the front.
Run this:
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall* | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -like 'Java 8'}

Then, try this:
Get-ItemProperty Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall* | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -like 'Java 8'}

@ghost
Copy link

ghost commented Aug 28, 2018

The commands are accepted, but I still can't install and receive the same Specified cast is not valid. error.

chocolatey.log:

2018-08-28 09:17:01,438 3596 [DEBUG] - XmlConfiguration is now operational
2018-08-28 09:17:01,477 3596 [INFO ] - ============================================================
2018-08-28 09:17:01,891 3596 [INFO ] - Chocolatey v0.10.11
2018-08-28 09:17:01,896 3596 [DEBUG] - Chocolatey is running on Windows v 10.0.17134.0
2018-08-28 09:17:01,897 3596 [DEBUG] - Attempting to delete file "c:/programdata/chocolatey/choco.exe.old".
2018-08-28 09:17:01,898 3596 [DEBUG] - Attempting to delete file "c:\programdata\chocolatey\choco.exe.old".
2018-08-28 09:17:01,912 3596 [DEBUG] - Command line: "c:\programdata\chocolatey\choco.exe" install jre8
2018-08-28 09:17:01,912 3596 [DEBUG] - Received arguments: install jre8
2018-08-28 09:17:01,953 3596 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
2018-08-28 09:17:01,959 3596 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers...
2018-08-28 09:17:01,964 3596 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed...
2018-08-28 09:17:02,398 3596 [DEBUG] - The source 'https://chocolatey.org/api/v2/' evaluated to a 'normal' source type
2018-08-28 09:17:02,400 3596 [DEBUG] - 
NOTE: Hiding sensitive configuration data! Please double and triple 
 check to be sure no sensitive data is shown, especially if copying 
 output to a gist for review.
2018-08-28 09:17:02,406 3596 [DEBUG] - Configuration: CommandName='install'|
CacheLocation='C:\Users\user\AppData\Local\Temp\chocolatey'|
ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='https://chocolatey.org/api/v2/'|SourceType='normal'|
Debug='False'|Verbose='False'|Trace='False'|Force='False'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='True'|AcceptLicense='False'|
AllowUnofficialBuild='False'|Input='jre8'|AllVersions='False'|
SkipPackageInstallProvider='False'|PackageNames='jre8'|
Prerelease='False'|ForceX86='False'|OverrideArguments='False'|
NotSilent='False'|ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Windows'|
Information.PlatformVersion='10.0.17134.0'|
Information.PlatformName='Windows 10'|
Information.ChocolateyVersion='0.10.11.0'|
Information.ChocolateyProductVersion='0.10.11'|
Information.FullName='choco, Version=0.10.11.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'|

Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='True'|
Information.UserName='user'|Information.UserDomainName='DESKTOP'|
Information.IsUserAdministrator='True'|
Information.IsUserSystemAccount='False'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='True'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'|
Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'|
Features.RemovePackageInformationOnUninstall='False'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='False'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'|
PinCommand.Command='unknown'|OutdatedCommand.IgnorePinned='False'|
Proxy.BypassOnLocal='True'|
2018-08-28 09:17:02,407 3596 [DEBUG] - _ Chocolatey:ChocolateyInstallCommand - Normal Run Mode _
2018-08-28 09:17:02,411 3596 [INFO ] - Installing the following packages:
2018-08-28 09:17:02,412 3596 [INFO ] - jre8
2018-08-28 09:17:02,412 3596 [INFO ] - By installing you accept licenses for the packages.
2018-08-28 09:17:03,995 3596 [INFO ] - [NuGet] Installing 'jre8 8.0.181'.
2018-08-28 09:17:04,000 3596 [DEBUG] - [NuGet] Added file 'chocolateyInstall.ps1' to folder 'jre8\tools'.
2018-08-28 09:17:04,002 3596 [DEBUG] - [NuGet] Added file 'chocolateyUninstall.ps1' to folder 'jre8\tools'.
2018-08-28 09:17:04,005 3596 [DEBUG] - [NuGet] Added file 'thisJreInstalled.ps1' to folder 'jre8\tools'.
2018-08-28 09:17:04,048 3596 [DEBUG] - [NuGet] Added file 'jre8.nuspec' to folder 'jre8'.
2018-08-28 09:17:04,050 3596 [DEBUG] - [NuGet] Added file 'jre8.nupkg' to folder 'jre8'.
2018-08-28 09:17:04,051 3596 [INFO ] - [NuGet] Successfully installed 'jre8 8.0.181'.
2018-08-28 09:17:04,052 3596 [INFO ] - 
jre8 v8.0.181 [Approved]
2018-08-28 09:17:04,065 3596 [INFO ] - jre8 package files install completed. Performing other installation steps.
2018-08-28 09:17:04,159 3596 [DEBUG] - Setting installer args for jre8
2018-08-28 09:17:04,160 3596 [DEBUG] - Setting package parameters for jre8
2018-08-28 09:17:04,160 3596 [DEBUG] - Contents of 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1':
2018-08-28 09:17:04,166 3596 [DEBUG] - try {

$arguments = @{}

  # Now we can use the $env:chocolateyPackageParameters inside the Chocolatey package
  $packageParameters = $env:chocolateyPackageParameters

  # Default value
  $exclude = $null

  # Now parse the packageParameters using good old regular expression
  if ($packageParameters) {
      $match_pattern = "\/(?<option>([a-zA-Z0-9]+)):(?<value>([`"'])?([a-zA-Z0-9- \(\)\s_\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
      $option_name = 'option'
      $value_name = 'value'

      if ($packageParameters -match $match_pattern ){
          $results = $packageParameters | Select-String $match_pattern -AllMatches
          $results.matches | % {
            $arguments.Add(
                $_.Groups[$option_name].Value.Trim(),
                $_.Groups[$value_name].Value.Trim())
        }
      }
      else
      {
          Throw "Package Parameters were found but were invalid (REGEX Failure)"
      }

      if($arguments.ContainsKey("exclude")) {
          Write-Host "exclude Argument Found"
          $exclude = $arguments["exclude"]
      }

  } else {
      Write-Debug "No Package Parameters Passed in"
  }

  $scriptDir = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
  
  $packageName = 'jre8'
  # Modify these values -----------------------------------------------------
  # Find download URLs at http://www.java.com/en/download/manual.jsp
  $url = 'https://javadl.oracle.com/webapps/download/AutoDL?BundleId=234472_96a7b8442fe848ef90c96a2fad6ed6d1'
  $checksum32 = '9E5E6A1C5D26D93454751E65486F728233FDAC3B50FF763F6709FB87DD960CE5'
  $url64 = 'https://javadl.oracle.com/webapps/download/AutoDL?BundleId=234474_96a7b8442fe848ef90c96a2fad6ed6d1'
  $checksum64 = 'CD2F756133D59525869ACB605A54EFD132FCD7EAF53E2EC040D92EF40A2EA60A'
  $oldVersion = '8.0.1710.11'
  $version = '8.0.1810.13'
  #--------------------------------------------------------------------------
  $homepath = $version -replace "(\d+\.\d+)\.(\d\d)(.*)",'jre1.$1_$2'
  $installerType = 'exe'
  $installArgs = "/s REBOOT=0 SPONSORS=0 AUTO_UPDATE=0 $32dir"
  $installArgs64 = "/s REBOOT=0 SPONSORS=0 AUTO_UPDATE=0 $64dir"
  $osBitness = Get-ProcessorBits
   
  Write-Output "Searching if new version exists..."
  $checkreg64 = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -like '*Java 8*' -and ([Version]$_.DisplayVersion) -eq $version} -ErrorAction SilentlyContinue
  $checkreg32 = Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -like '*Java 8*' -and ([Version]$_.DisplayVersion) -eq $version} -ErrorAction SilentlyContinue
  

    # Checks if JRE 32/64-bit in the same version is already installed and if the user excluded 32-bit Java.
    # Otherwise it downloads and installs it.
    # This is to avoid unnecessary downloads and 1603 errors.
    if ($checkreg32 -ne $null) 
    {
      Write-Output "Java Runtime Environment $version (32-bit) is already installed. Skipping download and installation"
    } 
    elseif ($exclude -ne "32") 
    {
      Write-Output "Installing JRE $version 32-bit"
      Install-ChocolateyPackage $packageName $installerType $installArgs $url -checksum $checksum32 -checksumtype 'sha256'
    } 
    else 
    {
      Write-Output "Java Runtime Environment $Version (32-bit) excluded for installation"
    }

    # Only check for the 64-bit version if the system is 64-bit

    if ($osBitness -eq 64) 
    {
      if ($checkreg64 -ne $null) 
      {
        Write-Output "Java Runtime Environment $version (64-bit) is already installed. Skipping download and installation"
      } 
      elseif ($exclude -ne "64") 
      {
        Write-Output "Installing JRE $version 64-bit"
        Install-ChocolateyPackage $packageName $installerType $installArgs64 -url64bit $url64 -checksum64 $checksum64 -checksumtype64 'sha256'
      } 
      else 
      {
        Write-Output "Java Runtime Environment $Version (64-bit) excluded for installation"
      }
    }
  
  #Uninstalls the previous version of Java if either version exists
  Write-Output "Searching if the previous version exists..."
  $checkoldreg64 = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, PSChildName | Where-Object { $_.DisplayName -like '*Java 8*' -and ([Version]$_.DisplayVersion) -eq $oldversion} -ErrorAction SilentlyContinue
  $checkoldreg32 = Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, PSChildName | Where-Object { $_.DisplayName -like '*Java 8*' -and ([Version]$_.DisplayVersion) -eq $oldversion} -ErrorAction SilentlyContinue
 
  if($checkoldreg32 -ne $null) 
  {
     Write-Warning "Uninstalling JRE version $oldVersion 32bit"
     $32 = $checkoldreg32.PSChildName
     Start-ChocolateyProcessAsAdmin "/qn /norestart /X$32" -exeToRun "msiexec.exe" -validExitCodes @(0,1605,3010)
  }
  if($checkoldreg64 -ne $null)
  {
     Write-Warning "Uninstalling JRE version $oldVersion $osBitness bit" #Formatted weird because this is used if run on a x86 install
     $64 = $checkoldreg64.PSChildName
     Start-ChocolateyProcessAsAdmin "/qn /norestart /X$64" -exeToRun "msiexec.exe" -validExitCodes @(0,1605,3010)
  }
} catch {
  #Write-ChocolateyFailure $packageName $($_.Exception.Message)
  throw
}

2018-08-28 09:17:04,167 3596 [INFO ] - The package jre8 wants to run 'chocolateyInstall.ps1'.
2018-08-28 09:17:04,168 3596 [INFO ] - Note: If you don't run this script, the installation will fail.
2018-08-28 09:17:04,169 3596 [INFO ] - Note: To confirm automatically next time, use '-y' or consider:
2018-08-28 09:17:04,170 3596 [INFO ] - choco feature enable -n allowGlobalConfirmation
2018-08-28 09:17:04,187 3596 [INFO ] - Do you want to run the script?
2018-08-28 09:17:04,188 3596 [INFO ] -  1) yes
2018-08-28 09:17:04,188 3596 [INFO ] -  2) no
2018-08-28 09:17:04,189 3596 [INFO ] -  3) print
2018-08-28 09:17:06,679 3596 [INFO ] - Choice selected: 'yes'
2018-08-28 09:17:06,695 3596 [DEBUG] - Calling built-in PowerShell host with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters ''']
2018-08-28 09:17:06,697 3596 [DEBUG] - Redirecting System.Management.Automation.resources, Version=3.0.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35, requested by ''
2018-08-28 09:17:06,908 3596 [DEBUG] - Host version is 5.1.17134.1, PowerShell Version is '5.1.17134.228' and CLR Version is '4.0.30319.42000'.
2018-08-28 09:17:07,690 3596 [INFO ] - VERBOSE: Exporting function 'Format-FileSize'.
2018-08-28 09:17:07,691 3596 [INFO ] - VERBOSE: Exporting function 'Get-ChecksumValid'.
2018-08-28 09:17:07,692 3596 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyUnzip'.
2018-08-28 09:17:07,692 3596 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyWebFile'.
2018-08-28 09:17:07,693 3596 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariable'.
2018-08-28 09:17:07,693 3596 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariableNames'.
2018-08-28 09:17:07,693 3596 [INFO ] - VERBOSE: Exporting function 'Get-FtpFile'.
2018-08-28 09:17:07,694 3596 [INFO ] - VERBOSE: Exporting function 'Get-OSArchitectureWidth'.
2018-08-28 09:17:07,694 3596 [INFO ] - VERBOSE: Exporting function 'Get-PackageParameters'.
2018-08-28 09:17:07,695 3596 [INFO ] - VERBOSE: Exporting function 'Get-PackageParametersBuiltIn'.
2018-08-28 09:17:07,695 3596 [INFO ] - VERBOSE: Exporting function 'Get-ToolsLocation'.
2018-08-28 09:17:07,696 3596 [INFO ] - VERBOSE: Exporting function 'Get-UACEnabled'.
2018-08-28 09:17:07,696 3596 [INFO ] - VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
2018-08-28 09:17:07,697 3596 [INFO ] - VERBOSE: Exporting function 'Get-VirusCheckValid'.
2018-08-28 09:17:07,697 3596 [INFO ] - VERBOSE: Exporting function 'Get-WebFile'.
2018-08-28 09:17:07,698 3596 [INFO ] - VERBOSE: Exporting function 'Get-WebFileName'.
2018-08-28 09:17:07,698 3596 [INFO ] - VERBOSE: Exporting function 'Get-WebHeaders'.
2018-08-28 09:17:07,699 3596 [INFO ] - VERBOSE: Exporting function 'Install-BinFile'.
2018-08-28 09:17:07,699 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyDesktopLink'.
2018-08-28 09:17:07,700 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyEnvironmentVariable'.
2018-08-28 09:17:07,700 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyExplorerMenuItem'.
2018-08-28 09:17:07,701 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyFileAssociation'.
2018-08-28 09:17:07,701 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyInstallPackage'.
2018-08-28 09:17:07,702 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPackage'.
2018-08-28 09:17:07,702 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPath'.
2018-08-28 09:17:07,703 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPinnedTaskBarItem'.
2018-08-28 09:17:07,703 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPowershellCommand'.
2018-08-28 09:17:07,704 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyShortcut'.
2018-08-28 09:17:07,704 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyVsixPackage'.
2018-08-28 09:17:07,705 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyZipPackage'.
2018-08-28 09:17:07,705 3596 [INFO ] - VERBOSE: Exporting function 'Install-Vsix'.
2018-08-28 09:17:07,706 3596 [INFO ] - VERBOSE: Exporting function 'Set-EnvironmentVariable'.
2018-08-28 09:17:07,706 3596 [INFO ] - VERBOSE: Exporting function 'Set-PowerShellExitCode'.
2018-08-28 09:17:07,707 3596 [INFO ] - VERBOSE: Exporting function 'Start-ChocolateyProcessAsAdmin'.
2018-08-28 09:17:07,707 3596 [INFO ] - VERBOSE: Exporting function 'Test-ProcessAdminRights'.
2018-08-28 09:17:07,707 3596 [INFO ] - VERBOSE: Exporting function 'Uninstall-BinFile'.
2018-08-28 09:17:07,708 3596 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyEnvironmentVariable'.
2018-08-28 09:17:07,708 3596 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyPackage'.
2018-08-28 09:17:07,709 3596 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyZipPackage'.
2018-08-28 09:17:07,709 3596 [INFO ] - VERBOSE: Exporting function 'Update-SessionEnvironment'.
2018-08-28 09:17:07,710 3596 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateyFailure'.
2018-08-28 09:17:07,710 3596 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateySuccess'.
2018-08-28 09:17:07,711 3596 [INFO ] - VERBOSE: Exporting function 'Write-FileUpdateLog'.
2018-08-28 09:17:07,711 3596 [INFO ] - VERBOSE: Exporting function 'Write-FunctionCallLogMessage'.
2018-08-28 09:17:07,712 3596 [INFO ] - VERBOSE: Exporting alias 'Get-ProcessorBits'.
2018-08-28 09:17:07,713 3596 [INFO ] - VERBOSE: Exporting alias 'Get-OSBitness'.
2018-08-28 09:17:07,713 3596 [INFO ] - VERBOSE: Exporting alias 'Get-InstallRegistryKey'.
2018-08-28 09:17:07,714 3596 [INFO ] - VERBOSE: Exporting alias 'Generate-BinFile'.
2018-08-28 09:17:07,714 3596 [INFO ] - VERBOSE: Exporting alias 'Add-BinFile'.
2018-08-28 09:17:07,715 3596 [INFO ] - VERBOSE: Exporting alias 'Start-ChocolateyProcess'.
2018-08-28 09:17:07,715 3596 [INFO ] - VERBOSE: Exporting alias 'Invoke-ChocolateyProcess'.
2018-08-28 09:17:07,716 3596 [INFO ] - VERBOSE: Exporting alias 'Remove-BinFile'.
2018-08-28 09:17:07,716 3596 [INFO ] - VERBOSE: Exporting alias 'refreshenv'.
2018-08-28 09:17:07,719 3596 [DEBUG] - Loading community extensions
2018-08-28 09:17:07,732 3596 [DEBUG] - Importing 'C:\ProgramData\chocolatey\extensions\chocolatey-core\chocolatey-core.psm1'
2018-08-28 09:17:07,734 3596 [INFO ] - VERBOSE: Loading module from path 'C:\ProgramData\chocolatey\extensions\chocolatey-core\chocolatey-core.psm1'.
2018-08-28 09:17:07,942 3596 [INFO ] - VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
2018-08-28 09:17:07,943 3596 [INFO ] - VERBOSE: Exporting function 'Get-AppInstallLocation'.
2018-08-28 09:17:07,943 3596 [INFO ] - VERBOSE: Exporting function 'Get-AvailableDriveLetter'.
2018-08-28 09:17:07,944 3596 [INFO ] - VERBOSE: Exporting function 'Get-EffectiveProxy'.
2018-08-28 09:17:07,944 3596 [INFO ] - VERBOSE: Exporting function 'Get-PackageCacheLocation'.
2018-08-28 09:17:07,945 3596 [INFO ] - VERBOSE: Exporting function 'Get-PackageParameters'.
2018-08-28 09:17:07,946 3596 [INFO ] - VERBOSE: Exporting function 'Get-WebContent'.
2018-08-28 09:17:07,946 3596 [INFO ] - VERBOSE: Exporting function 'Register-Application'.
2018-08-28 09:17:07,947 3596 [INFO ] - VERBOSE: Importing function 'Get-AppInstallLocation'.
2018-08-28 09:17:07,948 3596 [INFO ] - VERBOSE: Importing function 'Get-AvailableDriveLetter'.
2018-08-28 09:17:07,948 3596 [INFO ] - VERBOSE: Importing function 'Get-EffectiveProxy'.
2018-08-28 09:17:07,949 3596 [INFO ] - VERBOSE: Importing function 'Get-PackageCacheLocation'.
2018-08-28 09:17:07,949 3596 [INFO ] - VERBOSE: Importing function 'Get-PackageParameters'.
2018-08-28 09:17:07,950 3596 [INFO ] - VERBOSE: Importing function 'Get-UninstallRegistryKey'.
2018-08-28 09:17:07,950 3596 [INFO ] - VERBOSE: Importing function 'Get-WebContent'.
2018-08-28 09:17:07,951 3596 [INFO ] - VERBOSE: Importing function 'Register-Application'.
2018-08-28 09:17:07,952 3596 [DEBUG] - Importing 'C:\ProgramData\chocolatey\extensions\chocolatey-windowsupdate\chocolatey-windowsupdate.psm1'
2018-08-28 09:17:07,952 3596 [INFO ] - VERBOSE: Loading module from path 'C:\ProgramData\chocolatey\extensions\chocolatey-windowsupdate\chocolatey-windowsupdate.psm1'.
2018-08-28 09:17:08,090 3596 [INFO ] - VERBOSE: Exporting function 'Install-WindowsUpdate'.
2018-08-28 09:17:08,090 3596 [INFO ] - VERBOSE: Exporting function 'Test-WindowsUpdate'.
2018-08-28 09:17:08,091 3596 [INFO ] - VERBOSE: Importing function 'Install-WindowsUpdate'.
2018-08-28 09:17:08,091 3596 [INFO ] - VERBOSE: Importing function 'Test-WindowsUpdate'.
2018-08-28 09:17:08,092 3596 [INFO ] - VERBOSE: Exporting function 'Format-FileSize'.
2018-08-28 09:17:08,093 3596 [INFO ] - VERBOSE: Exporting function 'Get-ChecksumValid'.
2018-08-28 09:17:08,093 3596 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyUnzip'.
2018-08-28 09:17:08,093 3596 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyWebFile'.
2018-08-28 09:17:08,094 3596 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariable'.
2018-08-28 09:17:08,094 3596 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariableNames'.
2018-08-28 09:17:08,095 3596 [INFO ] - VERBOSE: Exporting function 'Get-FtpFile'.
2018-08-28 09:17:08,095 3596 [INFO ] - VERBOSE: Exporting function 'Get-OSArchitectureWidth'.
2018-08-28 09:17:08,096 3596 [INFO ] - VERBOSE: Exporting function 'Get-PackageParameters'.
2018-08-28 09:17:08,097 3596 [INFO ] - VERBOSE: Exporting function 'Get-PackageParametersBuiltIn'.
2018-08-28 09:17:08,097 3596 [INFO ] - VERBOSE: Exporting function 'Get-ToolsLocation'.
2018-08-28 09:17:08,098 3596 [INFO ] - VERBOSE: Exporting function 'Get-UACEnabled'.
2018-08-28 09:17:08,098 3596 [INFO ] - VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
2018-08-28 09:17:08,099 3596 [INFO ] - VERBOSE: Exporting function 'Get-VirusCheckValid'.
2018-08-28 09:17:08,099 3596 [INFO ] - VERBOSE: Exporting function 'Get-WebFile'.
2018-08-28 09:17:08,099 3596 [INFO ] - VERBOSE: Exporting function 'Get-WebFileName'.
2018-08-28 09:17:08,100 3596 [INFO ] - VERBOSE: Exporting function 'Get-WebHeaders'.
2018-08-28 09:17:08,100 3596 [INFO ] - VERBOSE: Exporting function 'Install-BinFile'.
2018-08-28 09:17:08,101 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyDesktopLink'.
2018-08-28 09:17:08,101 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyEnvironmentVariable'.
2018-08-28 09:17:08,102 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyExplorerMenuItem'.
2018-08-28 09:17:08,102 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyFileAssociation'.
2018-08-28 09:17:08,103 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyInstallPackage'.
2018-08-28 09:17:08,103 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPackage'.
2018-08-28 09:17:08,104 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPath'.
2018-08-28 09:17:08,104 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPinnedTaskBarItem'.
2018-08-28 09:17:08,105 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPowershellCommand'.
2018-08-28 09:17:08,105 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyShortcut'.
2018-08-28 09:17:08,106 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyVsixPackage'.
2018-08-28 09:17:08,106 3596 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyZipPackage'.
2018-08-28 09:17:08,107 3596 [INFO ] - VERBOSE: Exporting function 'Install-Vsix'.
2018-08-28 09:17:08,107 3596 [INFO ] - VERBOSE: Exporting function 'Set-EnvironmentVariable'.
2018-08-28 09:17:08,108 3596 [INFO ] - VERBOSE: Exporting function 'Set-PowerShellExitCode'.
2018-08-28 09:17:08,108 3596 [INFO ] - VERBOSE: Exporting function 'Start-ChocolateyProcessAsAdmin'.
2018-08-28 09:17:08,109 3596 [INFO ] - VERBOSE: Exporting function 'Test-ProcessAdminRights'.
2018-08-28 09:17:08,109 3596 [INFO ] - VERBOSE: Exporting function 'Uninstall-BinFile'.
2018-08-28 09:17:08,110 3596 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyEnvironmentVariable'.
2018-08-28 09:17:08,110 3596 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyPackage'.
2018-08-28 09:17:08,110 3596 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyZipPackage'.
2018-08-28 09:17:08,111 3596 [INFO ] - VERBOSE: Exporting function 'Update-SessionEnvironment'.
2018-08-28 09:17:08,111 3596 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateyFailure'.
2018-08-28 09:17:08,112 3596 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateySuccess'.
2018-08-28 09:17:08,112 3596 [INFO ] - VERBOSE: Exporting function 'Write-FileUpdateLog'.
2018-08-28 09:17:08,113 3596 [INFO ] - VERBOSE: Exporting function 'Write-FunctionCallLogMessage'.
2018-08-28 09:17:08,113 3596 [INFO ] - VERBOSE: Exporting function 'Get-AppInstallLocation'.
2018-08-28 09:17:08,114 3596 [INFO ] - VERBOSE: Exporting function 'Get-AvailableDriveLetter'.
2018-08-28 09:17:08,114 3596 [INFO ] - VERBOSE: Exporting function 'Get-EffectiveProxy'.
2018-08-28 09:17:08,115 3596 [INFO ] - VERBOSE: Exporting function 'Get-PackageCacheLocation'.
2018-08-28 09:17:08,115 3596 [INFO ] - VERBOSE: Exporting function 'Get-WebContent'.
2018-08-28 09:17:08,116 3596 [INFO ] - VERBOSE: Exporting function 'Register-Application'.
2018-08-28 09:17:08,116 3596 [INFO ] - VERBOSE: Exporting function 'Install-WindowsUpdate'.
2018-08-28 09:17:08,117 3596 [INFO ] - VERBOSE: Exporting function 'Test-WindowsUpdate'.
2018-08-28 09:17:08,117 3596 [INFO ] - VERBOSE: Exporting alias 'Get-ProcessorBits'.
2018-08-28 09:17:08,118 3596 [INFO ] - VERBOSE: Exporting alias 'Get-OSBitness'.
2018-08-28 09:17:08,118 3596 [INFO ] - VERBOSE: Exporting alias 'Get-InstallRegistryKey'.
2018-08-28 09:17:08,118 3596 [INFO ] - VERBOSE: Exporting alias 'Generate-BinFile'.
2018-08-28 09:17:08,119 3596 [INFO ] - VERBOSE: Exporting alias 'Add-BinFile'.
2018-08-28 09:17:08,119 3596 [INFO ] - VERBOSE: Exporting alias 'Start-ChocolateyProcess'.
2018-08-28 09:17:08,120 3596 [INFO ] - VERBOSE: Exporting alias 'Invoke-ChocolateyProcess'.
2018-08-28 09:17:08,120 3596 [INFO ] - VERBOSE: Exporting alias 'Remove-BinFile'.
2018-08-28 09:17:08,121 3596 [INFO ] - VERBOSE: Exporting alias 'refreshenv'.
2018-08-28 09:17:08,121 3596 [INFO ] - VERBOSE: Importing function 'Format-FileSize'.
2018-08-28 09:17:08,122 3596 [INFO ] - VERBOSE: Importing function 'Get-AppInstallLocation'.
2018-08-28 09:17:08,122 3596 [INFO ] - VERBOSE: Importing function 'Get-AvailableDriveLetter'.
2018-08-28 09:17:08,122 3596 [INFO ] - VERBOSE: Importing function 'Get-ChecksumValid'.
2018-08-28 09:17:08,123 3596 [INFO ] - VERBOSE: Importing function 'Get-ChocolateyUnzip'.
2018-08-28 09:17:08,123 3596 [INFO ] - VERBOSE: Importing function 'Get-ChocolateyWebFile'.
2018-08-28 09:17:08,124 3596 [INFO ] - VERBOSE: Importing function 'Get-EffectiveProxy'.
2018-08-28 09:17:08,124 3596 [INFO ] - VERBOSE: Importing function 'Get-EnvironmentVariable'.
2018-08-28 09:17:08,125 3596 [INFO ] - VERBOSE: Importing function 'Get-EnvironmentVariableNames'.
2018-08-28 09:17:08,125 3596 [INFO ] - VERBOSE: Importing function 'Get-FtpFile'.
2018-08-28 09:17:08,125 3596 [INFO ] - VERBOSE: Importing function 'Get-OSArchitectureWidth'.
2018-08-28 09:17:08,126 3596 [INFO ] - VERBOSE: Importing function 'Get-PackageCacheLocation'.
2018-08-28 09:17:08,126 3596 [INFO ] - VERBOSE: Importing function 'Get-PackageParameters'.
2018-08-28 09:17:08,127 3596 [INFO ] - VERBOSE: Importing function 'Get-PackageParametersBuiltIn'.
2018-08-28 09:17:08,127 3596 [INFO ] - VERBOSE: Importing function 'Get-ToolsLocation'.
2018-08-28 09:17:08,128 3596 [INFO ] - VERBOSE: Importing function 'Get-UACEnabled'.
2018-08-28 09:17:08,128 3596 [INFO ] - VERBOSE: Importing function 'Get-UninstallRegistryKey'.
2018-08-28 09:17:08,129 3596 [INFO ] - VERBOSE: Importing function 'Get-VirusCheckValid'.
2018-08-28 09:17:08,129 3596 [INFO ] - VERBOSE: Importing function 'Get-WebContent'.
2018-08-28 09:17:08,129 3596 [INFO ] - VERBOSE: Importing function 'Get-WebFile'.
2018-08-28 09:17:08,130 3596 [INFO ] - VERBOSE: Importing function 'Get-WebFileName'.
2018-08-28 09:17:08,130 3596 [INFO ] - VERBOSE: Importing function 'Get-WebHeaders'.
2018-08-28 09:17:08,131 3596 [INFO ] - VERBOSE: Importing function 'Install-BinFile'.
2018-08-28 09:17:08,131 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyDesktopLink'.
2018-08-28 09:17:08,132 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyEnvironmentVariable'.
2018-08-28 09:17:08,132 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyExplorerMenuItem'.
2018-08-28 09:17:08,133 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyFileAssociation'.
2018-08-28 09:17:08,133 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyInstallPackage'.
2018-08-28 09:17:08,134 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPackage'.
2018-08-28 09:17:08,134 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPath'.
2018-08-28 09:17:08,134 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPinnedTaskBarItem'.
2018-08-28 09:17:08,135 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPowershellCommand'.
2018-08-28 09:17:08,135 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyShortcut'.
2018-08-28 09:17:08,136 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyVsixPackage'.
2018-08-28 09:17:08,136 3596 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyZipPackage'.
2018-08-28 09:17:08,137 3596 [INFO ] - VERBOSE: Importing function 'Install-Vsix'.
2018-08-28 09:17:08,137 3596 [INFO ] - VERBOSE: Importing function 'Install-WindowsUpdate'.
2018-08-28 09:17:08,138 3596 [INFO ] - VERBOSE: Importing function 'Register-Application'.
2018-08-28 09:17:08,138 3596 [INFO ] - VERBOSE: Importing function 'Set-EnvironmentVariable'.
2018-08-28 09:17:08,139 3596 [INFO ] - VERBOSE: Importing function 'Set-PowerShellExitCode'.
2018-08-28 09:17:08,139 3596 [INFO ] - VERBOSE: Importing function 'Start-ChocolateyProcessAsAdmin'.
2018-08-28 09:17:08,139 3596 [INFO ] - VERBOSE: Importing function 'Test-ProcessAdminRights'.
2018-08-28 09:17:08,140 3596 [INFO ] - VERBOSE: Importing function 'Test-WindowsUpdate'.
2018-08-28 09:17:08,140 3596 [INFO ] - VERBOSE: Importing function 'Uninstall-BinFile'.
2018-08-28 09:17:08,141 3596 [INFO ] - VERBOSE: Importing function 'Uninstall-ChocolateyEnvironmentVariable'.
2018-08-28 09:17:08,141 3596 [INFO ] - VERBOSE: Importing function 'Uninstall-ChocolateyPackage'.
2018-08-28 09:17:08,142 3596 [INFO ] - VERBOSE: Importing function 'Uninstall-ChocolateyZipPackage'.
2018-08-28 09:17:08,142 3596 [INFO ] - VERBOSE: Importing function 'Update-SessionEnvironment'.
2018-08-28 09:17:08,143 3596 [INFO ] - VERBOSE: Importing function 'Write-ChocolateyFailure'.
2018-08-28 09:17:08,143 3596 [INFO ] - VERBOSE: Importing function 'Write-ChocolateySuccess'.
2018-08-28 09:17:08,144 3596 [INFO ] - VERBOSE: Importing function 'Write-FileUpdateLog'.
2018-08-28 09:17:08,144 3596 [INFO ] - VERBOSE: Importing function 'Write-FunctionCallLogMessage'.
2018-08-28 09:17:08,145 3596 [INFO ] - VERBOSE: Importing alias 'Add-BinFile'.
2018-08-28 09:17:08,145 3596 [INFO ] - VERBOSE: Importing alias 'Generate-BinFile'.
2018-08-28 09:17:08,145 3596 [INFO ] - VERBOSE: Importing alias 'Get-InstallRegistryKey'.
2018-08-28 09:17:08,146 3596 [INFO ] - VERBOSE: Importing alias 'Get-OSBitness'.
2018-08-28 09:17:08,146 3596 [INFO ] - VERBOSE: Importing alias 'Get-ProcessorBits'.
2018-08-28 09:17:08,147 3596 [INFO ] - VERBOSE: Importing alias 'Invoke-ChocolateyProcess'.
2018-08-28 09:17:08,147 3596 [INFO ] - VERBOSE: Importing alias 'refreshenv'.
2018-08-28 09:17:08,148 3596 [INFO ] - VERBOSE: Importing alias 'Remove-BinFile'.
2018-08-28 09:17:08,148 3596 [INFO ] - VERBOSE: Importing alias 'Start-ChocolateyProcess'.
2018-08-28 09:17:08,195 3596 [DEBUG] - Running 'ChocolateyScriptRunner' for jre8 v8.0.181 with packageScript 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1', packageFolder:'C:\ProgramData\chocolatey\lib\jre8', installArguments: '', packageParameters: '',
2018-08-28 09:17:08,206 3596 [DEBUG] - Running 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'
2018-08-28 09:17:08,233 3596 [DEBUG] - No Package Parameters Passed in
2018-08-28 09:17:08,249 3596 [DEBUG] - Running Get-ProcessorBits 
2018-08-28 09:17:08,253 3596 [INFO ] - Searching if new version exists...
2018-08-28 09:17:08,436 3596 [ERROR] - ERROR: Specified cast is not valid.
2018-08-28 09:17:08,440 3596 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters '''] exited with '-1'.
2018-08-28 09:17:08,442 3596 [DEBUG] - Calling command ['"C:\WINDOWS\System32\shutdown.exe" /a']
2018-08-28 09:17:08,470 3596 [DEBUG] - Command ['"C:\WINDOWS\System32\shutdown.exe" /a'] exited with '1116'
2018-08-28 09:17:08,585 3596 [DEBUG] - Capturing package files in 'C:\ProgramData\chocolatey\lib\jre8'
2018-08-28 09:17:08,587 3596 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\jre8.nupkg'
  with checksum '0B5EDF39443CCB6991A28E7B8798B499'
2018-08-28 09:17:08,587 3596 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\jre8.nuspec'
  with checksum 'CFEA3240CB37E74A003B46853472DCB1'
2018-08-28 09:17:08,588 3596 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'
  with checksum 'E83845E0C10018AF33580ABC480E415F'
2018-08-28 09:17:08,589 3596 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyUninstall.ps1'
  with checksum '4B7A4D65C739871EBC12A4D89EE2C603'
2018-08-28 09:17:08,589 3596 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\jre8\tools\thisJreInstalled.ps1'
  with checksum '11582402A4211505F6F5B024C7EBCEED'
2018-08-28 09:17:08,601 3596 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.arguments".
2018-08-28 09:17:08,602 3596 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.extra".
2018-08-28 09:17:08,602 3596 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.version".
2018-08-28 09:17:08,602 3596 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.sxs".
2018-08-28 09:17:08,603 3596 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\jre8.8.0.181\.pin".
2018-08-28 09:17:08,609 3596 [DEBUG] - Attempting to delete directory "C:\ProgramData\chocolatey\lib-bad\jre8".
2018-08-28 09:17:08,613 3596 [DEBUG] - Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers...
2018-08-28 09:17:08,614 3596 [ERROR] - The install of jre8 was NOT successful.
2018-08-28 09:17:08,616 3596 [ERROR] - Error while running 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'.
 See log for details.
2018-08-28 09:17:08,618 3596 [DEBUG] - Moving 'C:\ProgramData\chocolatey\lib\jre8'
 to 'C:\ProgramData\chocolatey\lib-bad\jre8'
2018-08-28 09:17:10,629 3596 [DEBUG] - Attempting to delete file "C:\Users\user\AppData\Local\NuGet\Cache\jre8.8.0.181.nupkg".
2018-08-28 09:17:10,636 3596 [WARN ] - 
Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
2018-08-28 09:17:10,638 3596 [INFO ] - 
2018-08-28 09:17:10,639 3596 [ERROR] - Failures
2018-08-28 09:17:10,639 3596 [ERROR] -  - jre8 (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\jre8\tools\chocolateyInstall.ps1'.
 See log for details.
2018-08-28 09:17:10,641 3596 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2018-08-28 09:17:10,649 3596 [DEBUG] - Exiting with -1

@CAKEbuilder
Copy link

The answer on Superuser.com was updated with more information.

From the comments, you get "Specified cast is not valid" when querying Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*. It is possible there is an unrelated key in this location that contains an invalid subkey, causing the query against this location to fail. We should be able to parse each key individually from the Uninstall location to determine which key we're having trouble querying.

Run the below:

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | % { write-host "Key Name:" $_.PSChildName }
This should return some results, then, will return the Specified cast error. The error will occur on the key harboring the invalid subkey.

For example, if the results of the above look like this:

Key Name: fake_key_name_1
Key Name: fake_key_name_2
Key Name: fake_key_name_3
Get-ItemProperty : Specified cast is not valid.

Then the last key you were able to successfully query was fake_key_name_3. The key we could not query was the next key in the list. Open regedit and browse to the next key name (presumably, fake_key_name_4). This is where the failure is. There should be an invalid subkey here. Fix this, then run the command again. If you get no errors, you're all set. If you get more keys with errors, find and fix their invalid subkeys.

In the case of one of the linked examples I originally provided, the user would expect to find a REG_DWORD key with data = "(invalid DWORD (32-bit) value)". This is the key to fix.

@proudcanadianeh
Copy link
Owner

Just wondering, were you able to follow that suggestion and find the invalid key? What did it turn out to be?

@ComFreek
Copy link

I am facing the same issue.
@proudcanadianeh as an answer to your comment on the Disqus package feed:

Just to confirm, after installing with the new file doing a clist -l does it list your jre8 version as 8.8.0.181.20180814?

Even with that new version (download link), I receive "ERROR: Specified cast is not valid." upon installation.

I could track down the offending registry key (by the SuperUser question linked above):

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\nbi-nb-base-8.2.0.0.201609300101\ | % { Write-Host "Key Name:" $_.PSChildName }

It's NetBeans! I've just found out the SuperUser question already mentioned three occurrences of the same error with NetBeans:

I've now uninstalled NetBeans, I didn't use it anyway.

@CAKEbuilder
Copy link

I'm glad the Superuser answer helped. I should probably write a more elegant way to check for the invalid key. The real problem is that this isn't an issue specific to this package, it's a general registry issue, so there's no single place to report the solution.

@ComFreek
Copy link

ComFreek commented Sep 27, 2018

There might be a single solution, though. Somewhere I read that there's a Chocolatey helper as a wrapper around querying the registry without causing this PowerShell bug.

I am a (co-)maintainer of the Netbeans Choco package, so if someone has a fix for the registry issue I could add to the chocolateyInstall.ps1, I'd be happy to do so.

@ghost
Copy link

ghost commented Sep 28, 2018

Sorry for the late reply. I also have NetBeans installed and didn't have issues with the package before NetBeans.

@proudcanadianeh
Copy link
Owner

Hmmm, I am curious about this choco wrapper that can prevent the error...

Is there any chance someone could export and upload a .reg file with the invalid entry in it? I want to do some troubleshooting but need to be able to replicate the issue first.

@proudcanadianeh
Copy link
Owner

Its about time I do something with this issue. After doing a bunch of research, this is a netbeans issue. There is an open request on their bug tracker about this and I dont think its really my place to try and do anything about this.
https://netbeans.org/bugzilla/show_bug.cgi?id=251538

Sorry I dont have better news :(

@jpluimers
Copy link

Workaround (in a future blog post at https://wiert.me) based on this StackOverflow answer :

  1. Run this from PowerShell

    Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | % { write-host "Key Name:" $_.PSChildName }

    This should return some results, then, will return the Specified cast error. The error will occur on the key harboring the invalid subkey.

  2. Then inspect the keys after that in regedit, and watch for any value of type REG_DWORD with a value (invalid DWORD (32-bit) value) (usually named NoModify)

  3. Note down those keys, and find them in appwiz.cpl

  4. Uninstall the accompanying software

  5. Repeat from step 1 until no failures occur

  6. Re-run choco install --yes jre8

Note that the script lists the Registry keys in insertion order, whereas RegEdit shows them in alphabetical order. Those orders usually differ a lot.

My PowerShell knowledge is not sufficient yet to:

  1. get all the registry keys under HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall, then for each item, loop one iteration.
  2. in the iteration, have an exception block, and try to get the values inside that key. If it fails: list the offending key name and exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants