Friday, 02 December, 2005

Enabling file name completion in Windows 2000

One of the reasons I started this diary was to document things that I'd found so that I don't have to go searching for them again.  If somebody else finds them useful, that's just a bonus.  Sometimes in the heat of finding and implementing a solution I forget to make a note and post it here.

I do a lot of work at the Windows command line, especially on the computer that I use to build release versions of the project.  When I set it up, I had to go searching for the magic incantations that would enable file name and path name completion on the command line.  I made the required changes and went on my merry way.  I hate it when I do that.  I set up another test machine a couple of months ago and couldn't remember the magic.  Since I don't use that machine much, I just let it slide.  Until the other day when I got fed up.

To enable file name and path name completion on the command line:

  1. Start RegEdit
  2. Navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor
  3. Set the CompletionChar value (add it as a REG_DWORD if it's not already there) to the value of the control key (in hexadecimal) that you want to use for file name completion.  I like using the Tab character, value 09.
  4. Set the PathCompletionChar value (add it as a REG_DWORD if it's not already there) to the value of the control key (in hexadecimal) that you want to use for path name completion.  I set this to Tab (value 09), too.
  5. Close RegEdit
  6. Start a new command window.  This change won't affect any command windows that were open before you made the registry changes.
  7. Change directories to the root of the C:\drive.
  8. Type "dir win" (without the quotes) and then hit the Tab key.  It should expand to dir "WINNT" or "dir Windows", depending on the name of your Windows directory.

Path and file name completion appears to be on by default in Windows XP Pro.  The odd thing is that the registry values are set to 0x40, but the Tab key still works.  In fact, no matter what values I use for these two settings, the Tab key still performs file and path name completion.  The values you set will work, too.  For example, if I set the PathCompletionChar value to 0x10 (Ctrl+P), then pressing Ctrl+P will complete the path, but so will pressing Tab.