Fixed notepad replacement
This commit is contained in:
parent
e136283a71
commit
b5b03e4dfe
3 changed files with 9 additions and 40 deletions
|
|
@ -499,7 +499,7 @@ if ($MyInvocation.InvocationName -ne ".") {
|
||||||
)
|
)
|
||||||
Start-Process -FilePath $DISM -ArgumentList $ArgumentList -NoNewWindow -Wait
|
Start-Process -FilePath $DISM -ArgumentList $ArgumentList -NoNewWindow -Wait
|
||||||
|
|
||||||
# Add WK tools
|
# Add tools
|
||||||
Write-Host "Copying tools..."
|
Write-Host "Copying tools..."
|
||||||
Copy-Item -Path "$Root\WK\$Arch" -Destination "$Mount\.bin" -Recurse -Force
|
Copy-Item -Path "$Root\WK\$Arch" -Destination "$Mount\.bin" -Recurse -Force
|
||||||
Copy-Item -Path "$Root\WK\_include\*" -Destination "$Mount\.bin" -Recurse -Force
|
Copy-Item -Path "$Root\WK\_include\*" -Destination "$Mount\.bin" -Recurse -Force
|
||||||
|
|
@ -538,17 +538,16 @@ if ($MyInvocation.InvocationName -ne ".") {
|
||||||
$RegKey = $Hive.OpenSubKey($RegPath)
|
$RegKey = $Hive.OpenSubKey($RegPath)
|
||||||
$CurValue = $RegKey.GetValue(
|
$CurValue = $RegKey.GetValue(
|
||||||
"Path", $false, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
|
"Path", $false, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
|
||||||
$NewValue = "$CurValue;%SystemDrive%\WK\7-Zip;%SystemDrive%\WK\python;%SystemDrive%\WK\wimlib"
|
$NewValue = "$CurValue;%SystemDrive%\.bin\7-Zip;%SystemDrive%\.bin\python;%SystemDrive%\.bin\wimlib"
|
||||||
Set-ItemProperty -Path "HKLM:\$RegPath" -Name "Path" -Value $NewValue -Force | Out-Null
|
Set-ItemProperty -Path "HKLM:\$RegPath" -Name "Path" -Value $NewValue -Force | Out-Null
|
||||||
$Hive.close()
|
$Hive.close()
|
||||||
$RegKey.close()
|
$RegKey.close()
|
||||||
|
|
||||||
# Replace Notepad
|
# Replace Notepad
|
||||||
## Currently broken ##
|
$RegPath = "HKLM:\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe"
|
||||||
# $RegPath = "HKLM:\WinPE-SW\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe"
|
$NewValue = 'cmd /c "%SystemDrive%\.bin\NotepadPlusPlus\npp.cmd"'
|
||||||
# $NewValue = 'wscript "X:\WK\NotepadPlusPlus\npp.vbs"'
|
New-Item -Path $RegPath -Force | Out-Null
|
||||||
# New-Item -Path $RegPath -Force | Out-Null
|
New-ItemProperty -Path $RegPath -Name "Debugger" -Value $NewValue -Force | Out-Null
|
||||||
# New-ItemProperty -Path $RegPath -Name "Debugger" -Value $NewValue -Force | Out-Null
|
|
||||||
|
|
||||||
# Run garbage collection to release potential stale handles
|
# Run garbage collection to release potential stale handles
|
||||||
## Credit: https://jrich523.wordpress.com/2012/03/06/powershell-loading-and-unloading-registry-hives/
|
## Credit: https://jrich523.wordpress.com/2012/03/06/powershell-loading-and-unloading-registry-hives/
|
||||||
|
|
|
||||||
3
WK/_include/NotepadPlusPlus/npp.cmd
Normal file
3
WK/_include/NotepadPlusPlus/npp.cmd
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
start "" %SystemDrive%\.bin\NotepadPlusPlus\notepadplusplus.exe %2 %3 %4 %5 %6 %7 %8 %9
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
'// DISCLAIMER
|
|
||||||
'// THIS COMES WITH NO WARRANTY, IMPLIED OR OTHERWISE. USE AT YOUR OWN RISK
|
|
||||||
'// IF YOU ARE NOT COMFORTABLE EDITING THE REGISTRY THEN DO NOT USE THIS SCRIPT
|
|
||||||
'//
|
|
||||||
'// NOTES:
|
|
||||||
'// This affects all users.
|
|
||||||
'// This will prevent ANY executable named notepad.exe from running located anywhere on this computer!!
|
|
||||||
'//
|
|
||||||
'// Save this text to your notepad++ folder as a text file named npp.vbs (some AV don't like vbs, get a different AV :-P )
|
|
||||||
'//
|
|
||||||
'// USAGE
|
|
||||||
'// 1)
|
|
||||||
'// Navigate to registry key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\
|
|
||||||
'//
|
|
||||||
' // 2)
|
|
||||||
'// Add new subkey called notepad.exe
|
|
||||||
'// This step is what tells windows to use the notepad++ exe, to undo simply delete this key
|
|
||||||
'//
|
|
||||||
'// 3)
|
|
||||||
'// Create new Sting Value called Debugger
|
|
||||||
'//
|
|
||||||
'// 4)
|
|
||||||
'// Modify value and enter wscript.exe "path to npp.vbs" e.g. wscript.exe "C:\Program Files\Notepad++\npp.vbs"
|
|
||||||
|
|
||||||
Option Explicit
|
|
||||||
Dim sCmd, x
|
|
||||||
sCmd = """" & LeftB(WScript.ScriptFullName, LenB(WScript.ScriptFullName) - LenB(WScript.ScriptName)) & "notepad++.exe" & """ """
|
|
||||||
For x = 1 To WScript.Arguments.Count - 1
|
|
||||||
sCmd = sCmd & WScript.Arguments(x) & " "
|
|
||||||
Next
|
|
||||||
sCmd = sCmd & """"
|
|
||||||
CreateObject("WScript.Shell").Run sCmd, 1, True
|
|
||||||
WScript.Quit
|
|
||||||
Loading…
Reference in a new issue