From 6a5a944ea0330dc14db936fb4c317f919f659a0a Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 9 Sep 2024 20:12:54 -0700 Subject: [PATCH] Refactor notepad replacement in WinPE The registry method has proved problematic. This DOSKEY method seems less error prone since it's evaluated at runtime. --- setup/pe/additions/Program Files/NotepadPlusPlus/npp.cmd | 3 --- setup/pe/additions/Windows/System32/custom.doskey | 3 ++- setup/pe/build_pe.ps1 | 6 ------ 3 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 setup/pe/additions/Program Files/NotepadPlusPlus/npp.cmd diff --git a/setup/pe/additions/Program Files/NotepadPlusPlus/npp.cmd b/setup/pe/additions/Program Files/NotepadPlusPlus/npp.cmd deleted file mode 100644 index f3817e41..00000000 --- a/setup/pe/additions/Program Files/NotepadPlusPlus/npp.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -start "" "%SystemDrive%\Program Files\NotepadPlusPlus\notepad++.exe" %2 %3 %4 %5 %6 %7 %8 %9 \ No newline at end of file diff --git a/setup/pe/additions/Windows/System32/custom.doskey b/setup/pe/additions/Windows/System32/custom.doskey index 57fc0442..90ae495b 100644 --- a/setup/pe/additions/Windows/System32/custom.doskey +++ b/setup/pe/additions/Windows/System32/custom.doskey @@ -1,4 +1,5 @@ +notepad="%ProgramFiles%\NotepadPlusPlus\notepad++.exe" $* poweroff=wpeutil shutdown reboot=wpeutil reboot restart=wpeutil reboot -shutdown=wpeutil shutdown \ No newline at end of file +shutdown=wpeutil shutdown diff --git a/setup/pe/build_pe.ps1 b/setup/pe/build_pe.ps1 index 2df3fae5..4cbc0ac8 100644 --- a/setup/pe/build_pe.ps1 +++ b/setup/pe/build_pe.ps1 @@ -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