Refactor notepad replacement in WinPE

The registry method has proved problematic.  This DOSKEY method seems
less error prone since it's evaluated at runtime.
This commit is contained in:
2Shirt 2024-09-09 20:12:54 -07:00
parent 3621914312
commit 6a5a944ea0
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 2 additions and 10 deletions

View file

@ -1,3 +0,0 @@
@echo off
start "" "%SystemDrive%\Program Files\NotepadPlusPlus\notepad++.exe" %2 %3 %4 %5 %6 %7 %8 %9

View file

@ -1,4 +1,5 @@
notepad="%ProgramFiles%\NotepadPlusPlus\notepad++.exe" $*
poweroff=wpeutil shutdown
reboot=wpeutil reboot
restart=wpeutil reboot
shutdown=wpeutil shutdown
shutdown=wpeutil shutdown

View file

@ -346,12 +346,6 @@ if ($MyInvocation.InvocationName -ne ".") {
$Hive.close()
$RegKey.close()
# Replace Notepad
$RegPath = "HKLM:\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe"
$NewValue = 'cmd /c "%ProgramFiles%\NotepadPlusPlus\npp.cmd"'
New-Item -Path $RegPath -Force | Out-Null
New-ItemProperty -Path $RegPath -Name "Debugger" -Value $NewValue -Force | Out-Null
# Run garbage collection to release potential stale handles
## Credit: https://jrich523.wordpress.com/2012/03/06/powershell-loading-and-unloading-registry-hives/
Start-Sleep -Seconds 2