You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After installing Chocolatey as SYSTEM, the following handled error is left in $Global:Error:
At C:\Windows\TEMP\chocolatey\chocInstall\tools\chocolateyInstall\helpers\functions\Set-EnvironmentVariable.ps1:81 char:5
+ $registryType = $win32RegistryKey.GetValueKind($Name)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at Set-EnvironmentVariable, C:\Windows\TEMP\chocolatey\chocInstall\tools\chocolateyInstall\helpers\functions\Set-EnvironmentVariable.ps1: line 81
at Install-ChocolateyEnvironmentVariable, C:\Windows\TEMP\chocolatey\chocInstall\tools\chocolateyInstall\helpers\functions\Install-ChocolateyEnvironmentVariable.ps1: line 100
at Set-ChocolateyInstallFolder, C:\Windows\TEMP\chocolatey\chocInstall\tools\chocolateysetup.psm1: line 166
at Initialize-Chocolatey, C:\Windows\TEMP\chocolatey\chocInstall\tools\chocolateysetup.psm1: line 78
at <ScriptBlock>, C:\Windows\TEMP\chocolatey\chocInstall\tools\chocolateyInstall.ps1: line 16
at <ScriptBlock>, <No file>: line 194
at <ScriptBlock>, E:\Build\WhsInit\Initialize-Computer.ps1: line 183
at <ScriptBlock>, <No file>: line 1
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException
What is Expected?
The code "handles" this exception with a try/catch block with an empty catch block. Unfortunately, PowerShell still puts handled excetpions in $Global:Error. I expect that handled errors should leave no errors in the $Global:Error array. (Our nightly process sends transcripts of its works and we get a report everyday of errors. These errors give use false negatives which lowers the likelihood we'll see real errors.)
How Did You Get This To Happen? (Steps to Reproduce)
Open a PowerShell prompt as SYSTEM: psexec -d -i -s powershell.exe.
Delete the ChocolateyInstall environment variable.
Install chocolatey.
After the install $Global:Error has the above error in it.
The text was updated successfully, but these errors were encountered:
splatteredbits
changed the title
Set-EnvironmentVariable writes an error when run as SYSTEM
Set-EnvironmentVariable writes an error when installing Chocolatey as SYSTEM
Nov 8, 2016
Set-EnvironmentVariable uses try/catch to handle when a registry key doesn't
exist. When running as SYSTEM, a local key may not exist, so an error is logged
as a warning.
Add explicit check to see if the environment variable registry
key exists before tring to get its type to avoid logging an error/warning.
What You Are Seeing?
After installing Chocolatey as SYSTEM, the following handled error is left in $Global:Error:
What is Expected?
The code "handles" this exception with a try/catch block with an empty catch block. Unfortunately, PowerShell still puts handled excetpions in $Global:Error. I expect that handled errors should leave no errors in the $Global:Error array. (Our nightly process sends transcripts of its works and we get a report everyday of errors. These errors give use false negatives which lowers the likelihood we'll see real errors.)
How Did You Get This To Happen? (Steps to Reproduce)
psexec -d -i -s powershell.exe
.The text was updated successfully, but these errors were encountered: