我正在安装一个巧克力包,它会引发错误:
Write-Error : [ERROR] Running C:\Users\username\AppData\Local\Temp\chocolatey\javaruntime\javaruntimeInstall.exe with /s REBOOT=Suppress was not successful. Exit code was '1603'.
At C:\ProgramData\chocolatey\chocolateyinstall\helpers\functions\Start-ChocolateyProcessAsAdmin.ps1:46 char:5
+ Write-Error $errorMessage
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Error
Write-Error : javaruntime did not finish successfully. Boo to the chocolatey gods!
-----------------------
错误显示在控制台中,但我找不到跟踪它的方法。之后的退出代码cinst javaruntime -force
为 0,并且包被移动到C:\ProgramData\chocolatey\lib-bad
. 我已经尝试使用 try-catch 捕获错误,但cinst
只是跳过它并在 try-catch 块之后执行。
有什么方法可以跟踪此类错误吗?
更新澄清:我的问题是,即使出现错误并且包被移动到 lib-bad,巧克力也会以代码 0 退出。
感谢您的帮助:D