Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use a trick to replace programs with another by making changes to the registry. This will work even if the program you are running uses absolute paths to run notepad. It overrides any instance of the running program with the chosen one no matter where it resides. And you won't have to patch the file. The key you'd be interested in is:</p> <pre><code>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options </code></pre> <p>Add a key with the name of the program and add a <code>Debugger</code> string with the path to the program you want to replace it with. Of course you need to have permissions to make the necessary modifications. This <a href="http://code.kliu.org/misc/notepad2/" rel="nofollow">page</a> explains how you can replace Windows Notepad with another program. You can apply the same process here.</p> <hr> <p>Though you'll probably not want to have this permanent change, so you can write up a program to temporarily add/change the key, run your program then change it back. Here's a complete one I just whipped up to temporarily replace Notepad with Word for a demonstration. Seems to work perfectly fine (though as always, use at your own risk). Just make all the necessary changes to fit your situation.</p> <pre><code>using System.Diagnostics; using Microsoft.Win32; namespace ProgramLauncher { class Program { // change the following constants as needed const string PROGRAM_NAME = @"notepad.exe"; const string REPLACEMENT_PATH = @"C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE"; const string RUNNING_PATH = @"C:\Windows\notepad.exe"; // root key const string KEY = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"; static void Main(string[] args) { using (var rootKey = Registry.LocalMachine.OpenSubKey(KEY, RegistryKeyPermissionCheck.ReadWriteSubTree)) { var oldPath = default(string); var needsRestoration = false; try { oldPath = BackupKey(rootKey, PROGRAM_NAME, REPLACEMENT_PATH); needsRestoration = true; Process.Start(RUNNING_PATH).WaitForExit(); } finally { if (needsRestoration) RestoreKey(rootKey, PROGRAM_NAME, oldPath); } } } static string BackupKey(RegistryKey rootKey, string programName, string newPath) { Debug.Assert(rootKey != null); Debug.Assert(!string.IsNullOrEmpty(programName)); Debug.Assert(!string.IsNullOrEmpty(newPath) &amp;&amp; System.IO.File.Exists(newPath)); if (newPath.Contains(" ")) newPath = string.Format("\"{0}\"", newPath); using (var programKey = rootKey.CreateSubKey(programName, RegistryKeyPermissionCheck.ReadWriteSubTree)) { var oldDebugger = programKey.GetValue("Debugger") as string; programKey.SetValue("Debugger", newPath, RegistryValueKind.String); return oldDebugger; } } static void RestoreKey(RegistryKey rootKey, string programName, string oldPath) { Debug.Assert(rootKey != null); Debug.Assert(!string.IsNullOrEmpty(programName)); if (oldPath != null) { using (var programKey = rootKey.OpenSubKey(programName, RegistryKeyPermissionCheck.ReadWriteSubTree)) programKey.SetValue("Debugger", oldPath); } else { rootKey.DeleteSubKey(programName); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload