How to Add “Copy as Path” to Right Click Menu in Windows XP

Windows Vista and higher already include the useful Copy as Path option in the context menu, which helps you quickly copy the complete path of the selected file(s) or folder(s) to the Clipboard. Here is how to add “Copy of Path” feature in Windows XP.

There are two methods discussed, both of them require the Clip.exe file from Microsoft. Clip.exe redirects command-line output to the Windows Clipboard. For example, typing the command dir | clip in a Command Prompt window places a copy of the current directory listing into the Windows clipboard.

Note: When using the Copy as Path command after following the steps in Method 1, you’ll see a Command Prompt window opening and closing briefly. Method 2 uses a VBScript which launches the Command Prompt window in invisible mode.

Download Clip.exe from the Microsoft FTP site here and save the file to your Windows directory.

(To open the Windows directory in your system, click Start → Run, type %systemroot%, and press Enter.)

Then, follow one of the methods below.

Add “Copy as Path” to Right Click Menu

  1. Download copypath.reg and save it to the Desktop.
  2. Right-click on the file and choose Merge.
  3. Click Yes when asked for confirmation.

This adds the following registry key:

HKEY_CLASSES_ROOT\Allfilesystemobjects\shell\CopyPath\command

and sets the (default) value to:

%comspec% /c <nul (set/p anyvariable="%1")|clip.exe

You’ll see the “Copy as Path” option when you right-click a file or folder.



Note: Previously it was %comspec% /c echo “%1″|clip.exe, but since that adds a line feed, I had to change the command-line as above. Thanks to Eric.

Using a Script

To automate the above task of adding or removing the Copy as Path menu option, you can use this script as an alternative.

  1. Download copypath.zip extract the script file copypath.vbs file to your Windows directory.
  2. Double-click copypath.vbs to run it.
  3. Click Ok when you see the following prompt:

(To remove the Copy as Path context menu option, double-click the copypath.vbs file, type UNINSTALL and click Ok. Then delete the file copypath.vbs manually from your Windows directory.)

After following one of the methods above, “Copy as Path” option will be added to the context menu. To copy a file or folder path to Clipboard, press and hold the Shift key, right-click on the file or folder and click “Copy as Path”.

Additional Tip: If you want to make the Copy as Path command always available (without needing to use the SHIFT key), simply delete the value named Extended in the registry location below, using the Registry Editor:

HKEY_CLASSES_ROOT\Allfilesystemobjects\shell\CopyPath

See also: How to Add “Open File Location” Right-Click Option in Windows XP


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

11 thoughts on “How to Add “Copy as Path” to Right Click Menu in Windows XP”

  1. Nevermind, figured it out myself.

    After a little digging, I found this page: https://www.winhelponline.com/blog/add-copy-as-path-option-to-the-context-menu-in-windows-xp/

    So, if using your Method 2, replace line 20 and 21, which were:
    WshShell.run “%comspec% /c ” & “echo ” & chr(34) & _
    WScript.Arguments.Item(0) & chr(34) & “| clip.exe”,0

    with:

    WshShell.run “%comspec% /c ” & “<nul (set/p anyvariable=” & chr(34) & _
    WScript.Arguments.Item(0) & chr(34) & “)| clip.exe”,0

    This gives you the bonus of no quote marks as well.

    Or, if using Method 1, use regedit to replace the value in HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\CopyPath\command
    Originally, this is: %comspec% /c echo “%1″|clip.exe
    Change it to: %comspec% /c <nul (set/p anyvariable=”%1”)|clip.exe

    Reply
  2. I had to remove the quotes from the copied text to work with the web app I’m pasting a path into. Goto HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\CopyPath\command and alter the default key to %comspec% /c echo %1|clip.exe , really just removing the quotes from around the percent1 pipe clip.exe

    Reply
  3. Awe_some!

    I just discovered your site, Ramesh, and I wish I’d discovered it five years ago! I’m finding so many little tips I wish I’d had — Download Places (got rid of the default My Documents, that I never use) — this one, which saves a LOT of hand-typing as well as clicking … I’m sure I’ll find many more! Can’t wait to browse the rest of the site.

    Thank you, thank you, thank you!

    Reply
    • To remove the Copy as Path context menu option, double-click the copypath.vbs file, type UNINSTALL and press ENTER. Then delete the file copypath.vbs manually from your Windows directory.

  4. Is there any way to modify the program to use the full network address to a mapped drive rather than the letter name? For example: “\\servername\folder\file” rather than “X:\folder\file”

    Reply
  5. Followed this to the letter. It copied the object as a named object and all the contents within the file. I just wanted the file name.

    Reply
  6. Hello,
    Is there a way (some additional switches in presented command) to suppress appearance of the CMD window?
    Also – why is the command encoded into some hex string? Can’t this be added into registry (and thus written within .reg file) in more user understandable form?

    Reply
    • @Epic: Since it’s an expandable string value (%comspec%), it has to be REG_EXPAND_SZ value type instead of REG_SZ. So, it’s showing as hex string in the text file.

      Note that you can also use cmd.exe (REG_SZ value should be fine) instead of %comspec%.

Leave a Reply to neil Cancel reply