use*_*527 5 powershell chocolatey
我目前在安装Java SE 运行时环境( )时收到此错误jre8,更新过去可以正常工作:
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.
Run Code Online (Sandbox Code Playgroud)
巧克力日志(由于 30 000 个字符的长度限制,我无法在此处粘贴,我已删除了日期)
此错误似乎是失败的结果Get-ItemProperty。从您的日志中,脚本失败的部分位于此处:
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
Run Code Online (Sandbox Code Playgroud)
Get-ItemProperty当期望读取类型 X 的注册表项并读取其数据与项类型的约束不匹配的项时,会发生此失败。研究1 研究2 研究3
这种情况下的解决方案是在注册表中找到无效的键(在$checkreg64和中查询的注册表路径$checkreg32)并手动将其重新创建为值为 1 的 DWORD。
更新:
从评论中,您在查询时得到“指定的强制转换无效” Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*。此位置中可能存在一个不相关的键,其中包含无效的子键,从而导致针对此位置的查询失败。我们应该能够从卸载位置单独解析每个密钥,以确定我们在查询时遇到问题的密钥。
运行以下命令:
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | % { write-host "Key Name:" $_.PSChildName }
Run Code Online (Sandbox Code Playgroud)
这应该返回一些结果,然后,将返回错误Specified cast。该错误将发生在包含无效子项的密钥上。
例如,如果上面的结果如下所示:
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.
Run Code Online (Sandbox Code Playgroud)
那么您能够成功查询的最后一个键是fake_key_name_3。我们无法查询的键是列表中的下一个键。打开 regedit 并浏览到下一个键名(大概是fake_key_name_4)。这就是失败的地方。这里应该有一个无效的子项。修复此问题,然后再次运行该命令。如果没有出现错误,则一切就绪。如果您获得更多有错误的密钥,请查找并修复它们的无效子密钥。
在我最初提供的链接示例之一中,用户希望找到一个带有 data =“(无效的 DWORD(32 位)值)”的 REG_DWORD 键。这是修复的关键。
我刚刚遇到这个问题。我做了:
get-childitem hklm:\software\microsoft\windows\currentversion\uninstall\ |
foreach { write-host $_.pspath; $_ } | get-itemproperty
Run Code Online (Sandbox Code Playgroud)
它被 窒息了HKLM:\software\microsoft\windows\currentversion\uninstall\nbi-nb-base-8.2.0.0.201609300101,这是针对 Netbeans 8.2 的。我在 regedit 中看到 NoModify 有“(无效的 DWORD(32 位)值)”。 get-itemproperty -erroraction continue没有影响。
编辑:Netbeans 人员目前终于解决了这个问题(不是真的)。 https://issues.apache.org/jira/browse/NETBEANS-2523
编辑:他们可能永远不会修复它。
| 归档时间: |
|
| 查看次数: |
8731 次 |
| 最近记录: |