Skip to content

Commit

Permalink
(chocolateyGH-1604) Fix DateTime formatting issue in Env:ChocolateyLa…
Browse files Browse the repository at this point in the history
…stPathUpdate

Due to the DateTime format used this would cause all kinds of issues when a tool or environment uses the environment variables.
For example, a python script that reads all environment variables on a system with a Swedish DateTime culture set and tries to serialize the key/values
as JSON would/could error out when a ÅÄ or Ö is written by choco into ChocolateyLastPathUpdate, it's also a hard bug to track down since in the
Swedish case it would only trigger on a Saturday, Sunday or Monday where mentioned chars would appear.

This change changes the formatting used to force it to a long in the form of using ToFileTime() on the returned Date object instead of the formatting
flags used before the change.
  • Loading branch information
Marcus Grenängen committed Feb 4, 2019
1 parent 0c720d6 commit e9a2ef5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static extern IntPtr SendMessageTimeout(

# Set a user environment variable making the system refresh
$setx = "$($env:SystemRoot)\System32\setx.exe"
& "$setx" ChocolateyLastPathUpdate `"$(Get-Date -UFormat %c)`" | Out-Null
& "$setx" ChocolateyLastPathUpdate `"$((Get-Date).ToFileTime())`" | Out-Null
} catch {
Write-Warning "Failure attempting to let Explorer know about updated environment settings.`n $($_.Exception.Message)"
}
Expand Down

0 comments on commit e9a2ef5

Please sign in to comment.