Finally, I found a solution that works for me:
(get-item hkcu:\Environment).GetValue('tmp', $null, 'DoNotExpandEnvironmentNames')
I found this GetValue overload after writing the following PowerShell / C # code:
$reg = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey("Environment", $true);
$val = $reg.GetValue('tmp', $null, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
$val
$reg.Close()
source
share