'// 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, the same key under HKCU did not work for me
'// This vbscript was written by selyb on 08-28-09
'// This txt looks no good with word wrap on :-P
'//
'// Save this text to your hdd as a text file named *.vbs e.g. "C:\IFEO.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 with the name of the executable you want replaced (no path) e.g. notepad.exe
'// This step is what tells windows to use the replacement exe, to undo simply delete the key you created
'//
'// 3)
'// Create new Sting Value called Debugger
'//
'// 4)
'// Modify value and enter wscript.exe "path to this vbs" e.g. wscript.exe "C:\IFEO.vbs"
'//
'// 5)
'// Under DEFINITIONS section below, create a new definition using an example as a template
'// If you add the registry entry and then try to execute it without creating a definition,
'// this file will open automatically in notepad
'// The definitions below will do NOTHING without the corresponding subkey created in step 2
Option Explicit
Dim sCmd, sFol, x, bWait, W
Set W = CreateObject("WScript.Shell")
sCmd = Split(WScript.Arguments(0), "\")
x = LCase(sCmd(UBound(sCmd)))
bWait = False
Select Case x
'// DEFINITIONS
'// Map
'// This must be lower case and must be the exact same name of the subkey you created in the registry
' Case "notepad.exe"
'// This is the command to be executed, you can put command line parameters here too
' sCmd = "replacement.exe"
'// This is the path you want the command executed from (may be omitted)
' sFol = "C:\Program Files\Replacement"
'// If true, wscript.exe will not terminate until the replacement is closed (False if omitted)
'// I needed this true with notepad.exe because 7-zip would delete the file before the replacement would open it >:-/
' bWait = True
'// example 1 (remove the single quot marks after you paste)
'Case "notepad.exe"
'sCmd = "replacement.exe /y /z"
'sFol = "C:\Program Files\Replacement"
'bWait = True
'// example 2 (If sCmd has a space in the name, you need triple quotes)
'Case "calc.exe"
'sCmd = """C:\Users\My Name\Downloads\newcalc.exe"""
'// example 3 (If sCmd has a space and you need additional command line params, it gets complicated)
'Case "taskmgr.exe"
'sCmd """C:\one folder\two folder\new app.exe"" /x /y /z"
'sFol """C:\windows\system32"
'// END OF DEFINITIONS
Case else
W.Run "notepad.exe """ & WScript.ScriptFullName & """", 8, False
WScript.Sleep(2000)
WScript.Echo x & " not defined yet." & vbNewLine & "Please add definition for it."
WScript.Quit
End Select
If LenB(sFol) Then W.CurrentDirectory = sFol
For x = 1 To WScript.Arguments.Count - 1
sCmd = sCmd & " """ & WScript.Arguments(x) & """"
Next
W.Run sCmd, 1, bWait
WScript.Quit
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you detail under which OS versions you got the script running?
Does the script work under UAC and restricted privileges?
Tester input appreciated.
This works for Windows NT/2K/XP/Server 2K3/Vista/Server 2K8/Win7
You must have Administrator privileges to write to the registry key.
I wrote a complete tutorial and some sample scripts.
*sigh* I didn't realize I had already linked to the tut in my first post and SF will not let me edit my posts >:-\
anyway, I have updated the tutorial several times since that first post
To tailor NPP to support this method, you could add a command line option to ignore the following argument e.g. /ignore "uneeded data"
This way, we could bypass the need for the vbscript and call NPP directly.
For this to work, the Debugger value would need /ignore at the end of the string after any custom command line arguments.
OTOH, I can write a simple script tailored for NPP that could be included in install and requires not change to source
You may contact me via email
user: sourceforge
domain: thefamilycirc.us
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2012-04-18
For opening files with spaces you need this script
'// 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
'// If the argument contains a space then enclose it with ""
If InStrB(WScript.Arguments(x), " ") Then
sCmd = sCmd & " """ & WScript.Arguments(x) & """"
Else
sCmd = sCmd & " " & WScript.Arguments(x)
End If
'//sCmd = sCmd & " """ & WScript.Arguments(x) & """"
Next
CreateObject("WScript.Shell").Run sCmd, 1, True
WScript.Quit
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
full Tutorial: http://www.vistax64.com/tutorials/244527-use-system-program-replacements-without-modifying-system-files-permissions.html
'// 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, the same key under HKCU did not work for me
'// This vbscript was written by selyb on 08-28-09
'// This txt looks no good with word wrap on :-P
'//
'// Save this text to your hdd as a text file named *.vbs e.g. "C:\IFEO.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 with the name of the executable you want replaced (no path) e.g. notepad.exe
'// This step is what tells windows to use the replacement exe, to undo simply delete the key you created
'//
'// 3)
'// Create new Sting Value called Debugger
'//
'// 4)
'// Modify value and enter wscript.exe "path to this vbs" e.g. wscript.exe "C:\IFEO.vbs"
'//
'// 5)
'// Under DEFINITIONS section below, create a new definition using an example as a template
'// If you add the registry entry and then try to execute it without creating a definition,
'// this file will open automatically in notepad
'// The definitions below will do NOTHING without the corresponding subkey created in step 2
Option Explicit
Dim sCmd, sFol, x, bWait, W
Set W = CreateObject("WScript.Shell")
sCmd = Split(WScript.Arguments(0), "\")
x = LCase(sCmd(UBound(sCmd)))
bWait = False
Select Case x
'// DEFINITIONS
'// Map
'// This must be lower case and must be the exact same name of the subkey you created in the registry
' Case "notepad.exe"
'// This is the command to be executed, you can put command line parameters here too
' sCmd = "replacement.exe"
'// This is the path you want the command executed from (may be omitted)
' sFol = "C:\Program Files\Replacement"
'// If true, wscript.exe will not terminate until the replacement is closed (False if omitted)
'// I needed this true with notepad.exe because 7-zip would delete the file before the replacement would open it >:-/
' bWait = True
'// example 1 (remove the single quot marks after you paste)
'Case "notepad.exe"
'sCmd = "replacement.exe /y /z"
'sFol = "C:\Program Files\Replacement"
'bWait = True
'// example 2 (If sCmd has a space in the name, you need triple quotes)
'Case "calc.exe"
'sCmd = """C:\Users\My Name\Downloads\newcalc.exe"""
'// example 3 (If sCmd has a space and you need additional command line params, it gets complicated)
'Case "taskmgr.exe"
'sCmd """C:\one folder\two folder\new app.exe"" /x /y /z"
'sFol """C:\windows\system32"
'// END OF DEFINITIONS
Case else
W.Run "notepad.exe """ & WScript.ScriptFullName & """", 8, False
WScript.Sleep(2000)
WScript.Echo x & " not defined yet." & vbNewLine & "Please add definition for it."
WScript.Quit
End Select
If LenB(sFol) Then W.CurrentDirectory = sFol
For x = 1 To WScript.Arguments.Count - 1
sCmd = sCmd & " """ & WScript.Arguments(x) & """"
Next
W.Run sCmd, 1, bWait
WScript.Quit
Could you detail under which OS versions you got the script running?
Does the script work under UAC and restricted privileges?
Tester input appreciated.
At any rate, this script will be put oon http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Replacing_Notepad
CChris
This works for Windows NT/2K/XP/Server 2K3/Vista/Server 2K8/Win7
You must have Administrator privileges to write to the registry key.
I wrote a complete tutorial and some sample scripts.
http://www.vistax64.com/tutorials/244527-programs-replace-system-program-without-modifying-system-files-permissions.html
*sigh* I didn't realize I had already linked to the tut in my first post and SF will not let me edit my posts >:-\
anyway, I have updated the tutorial several times since that first post
To tailor NPP to support this method, you could add a command line option to ignore the following argument e.g. /ignore "uneeded data"
This way, we could bypass the need for the vbscript and call NPP directly.
For this to work, the Debugger value would need /ignore at the end of the string after any custom command line arguments.
OTOH, I can write a simple script tailored for NPP that could be included in install and requires not change to source
You may contact me via email
user: sourceforge
domain: thefamilycirc.us
For opening files with spaces you need this script
'// 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
'// If the argument contains a space then enclose it with ""
If InStrB(WScript.Arguments(x), " ") Then
sCmd = sCmd & " """ & WScript.Arguments(x) & """"
Else
sCmd = sCmd & " " & WScript.Arguments(x)
End If
'//sCmd = sCmd & " """ & WScript.Arguments(x) & """"
Next
CreateObject("WScript.Shell").Run sCmd, 1, True
WScript.Quit