Bugfix: REG_EXPAND_SZ keys now handled correctly
This commit is contained in:
parent
675ff57f66
commit
330b24641f
1 changed files with 13 additions and 4 deletions
|
|
@ -526,10 +526,18 @@ if ($MyInvocation.InvocationName -ne ".") {
|
||||||
Start-Process -FilePath $Reg -ArgumentList $ArgumentList -NoNewWindow -Wait
|
Start-Process -FilePath $Reg -ArgumentList $ArgumentList -NoNewWindow -Wait
|
||||||
|
|
||||||
# Add tools to path
|
# Add tools to path
|
||||||
$RegPath = "HKLM:\WinPE-SYS\ControlSet001\Control\Session Manager\Environment"
|
## .NET code to properly handle REG_EXPAND_SZ values
|
||||||
$RegKey = Get-ItemProperty -Path $RegPath
|
## Credit: https://www.sepago.com/blog/2013/08/22/reading-and-writing-regexpandsz-data-with-powershell
|
||||||
$NewValue = "{0};%SystemDrive%\WK\7-Zip;%SystemDrive%\WK\python;%SystemDrive%\WK\wimlib" -f $RegKey.Path
|
## By: Marius Gawenda
|
||||||
Set-ItemProperty -Path $RegPath -Name "Path" -Value $NewValue -Force | Out-Null
|
$Hive = [Microsoft.Win32.Registry]::LocalMachine
|
||||||
|
$RegPath = "WinPE-SYS\ControlSet001\Control\Session Manager\Environment"
|
||||||
|
$RegKey = $Hive.OpenSubKey($RegPath)
|
||||||
|
$CurValue = $RegKey.GetValue(
|
||||||
|
"Path", $false, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
|
||||||
|
$NewValue = "$CurValue;%SystemDrive%\WK\7-Zip;%SystemDrive%\WK\python;%SystemDrive%\WK\wimlib"
|
||||||
|
Set-ItemProperty -Path "HKLM:\$RegPath" -Name "Path" -Value $NewValue -Force | Out-Null
|
||||||
|
$Hive.close()
|
||||||
|
$RegKey.close()
|
||||||
|
|
||||||
# Replace Notepad
|
# Replace Notepad
|
||||||
## Currently broken ##
|
## Currently broken ##
|
||||||
|
|
@ -560,5 +568,6 @@ if ($MyInvocation.InvocationName -ne ".") {
|
||||||
|
|
||||||
## Done ##
|
## Done ##
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
Write-Host "`nDone."
|
||||||
WKPause "Press Enter to exit... "
|
WKPause "Press Enter to exit... "
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue