locked
Copy As Path RRS feed

  • Question

  • I use the Copy As Path command from the shift+right-click menu in Windows Explorer a lot. Is there any way to get this command to show up on the regular context menu so that I don't need to hold Shift every time I want to get to it? I recall somewhere seeing a registry edit that would do this in Vista but I can't find it now...

    I'm also wondering if there might be any trick to copying the path without the quotes on either end. Usually the quotes are helpful, but there are cases where I need the path without the quotes.

    Thanks.
    Saturday, June 20, 2009 2:50 PM

Answers

  • Here's the solution I've ended up using which works pretty well for me and doesn't flash any command prompt windows:

    I created a small script using the Autohotkey (www.autohotkey.com) scripting language which just copies any argument passed to it to the clipboard. I then added the appropriate registry entries to add the commands to the right-click menu and pass the path as an argument to the sript.

    Here's the script file contents:
    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    #NoTrayIcon
    
    clipboard=%1%
    
    and a sample registry file:

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\*\shell\Copy Path\command]
    @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"D:\\Documents\\autohotkey\\Copy Path.ahk\" \"%1\""
    
    [HKEY_CLASSES_ROOT\*\shell\Copy Path ""\command]
    @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"D:\\Documents\\autohotkey\\Copy Path.ahk\" \\\"\"%1\"\\\""
    
    [HKEY_CLASSES_ROOT\Folder\shell\Copy Path\command]
    @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"D:\\Documents\\autohotkey\\Copy Path.ahk\" \"%1\""
    
    [HKEY_CLASSES_ROOT\Folder\shell\Copy Path ""\command]
    @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"D:\\Documents\\autohotkey\\Copy Path.ahk\" \\\"\"%1\"\\\""
    You'd have to edit the registry file as appropriate for your needs/file location.

    I've uploaded a zip file with the script and .reg file as well as a compiled version of the script that you can use if you don't want to install Autohotkey on your system. Here's a link to the file:
    http://www.box.net/shared/p6dot70fjf
    • Marked as answer by Magritte Saturday, December 5, 2009 7:32 PM
    Saturday, December 5, 2009 7:29 PM
  • You are correct Ronnie.  That is exactly what I presently do.  In addition I press F2, Ctl+C, esc to copy the filename after pasting the path.

    Windows XP/2003 used to allow you to simply tab to the address bar where you could press Ctl+C to copy, and do it all using the keyboard.  But now, you can highlight the file, press Shift+MenuKey, then "a" to copy as path to the clipboard.  This is actually simpler.
    Saturday, June 20, 2009 11:35 PM
  • The best solution I've found to get the same functionality on the main right-click menu is through the use of the freeware program "Send To Toys" by Gabriele Ponti: http://www.gabrieleponti.com/software/

    This program works great in both Windows 7 and Vista and provides some handy configurability, like for example the ability to use quotes around paths to folders with spaces in them.



    Note that you don't have to install all the toys.

    -Noel





    • Proposed as answer by Noel Carboni Friday, December 4, 2009 4:41 AM
    • Marked as answer by Ronnie VernonMVP Saturday, December 5, 2009 7:44 AM
    Friday, December 4, 2009 4:40 AM

All replies

  • Magritte,

    Is this the article you were looking for?
    Saturday, June 20, 2009 10:31 PM
    Answerer
  • Magritte,

    All I was able to find for Windows Vista or newer was this forum post, which elaborates on how to remove the command from the right click + Shift menu only. A user elaborates on a somewhat cryptic way of actually adding this to the regular right-click menu, but his registry hack seems unfinished such as he posted it.

    Clip.exe does exist in System32 in Windows 7, however.
    -Alex
    Saturday, June 20, 2009 10:40 PM
  • I tried the registry hack in the article and it works.  It is not as elegant as the real one because it flashes a cmd window while doing it's work.

    To copy the path without quotes, simply remove the quotes around %1 in @ (default) in HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\CopyPath\command.
    Saturday, June 20, 2009 10:50 PM
  • Hi Magritte

    I try to keep the context menus as small as possible.

    If I want to copy the path, I have gotten used to simply clicking an empty spot in the Address Bar, which shows the path already highlighted. I can then right click the highlighted path and select Copy.

    It ends up being one more click, but you don't need to hold Shift and it also gets rid of the Quotes.

    Hope this helps.


    Thank You for testing Windows 7

    Ronnie Vernon MVP
    Saturday, June 20, 2009 11:10 PM
  • You are correct Ronnie.  That is exactly what I presently do.  In addition I press F2, Ctl+C, esc to copy the filename after pasting the path.

    Windows XP/2003 used to allow you to simply tab to the address bar where you could press Ctl+C to copy, and do it all using the keyboard.  But now, you can highlight the file, press Shift+MenuKey, then "a" to copy as path to the clipboard.  This is actually simpler.
    Saturday, June 20, 2009 11:35 PM
  • I tried the registry hack in the article and it works.  It is not as elegant as the real one because it flashes a cmd window while doing it's work.

    To copy the path without quotes, simply remove the quotes around %1 in @ (default) in HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\CopyPath\command.

    Is this for Windows XP or Vista?  I use Vista and I do not have a "HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\CopyPath\command" entry only "HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\CopyAsPathMenu".
    Monday, October 12, 2009 10:34 PM
  • Hi Magritte

    I try to keep the context menus as small as possible.

    If I want to copy the path, I have gotten used to simply clicking an empty spot in the Address Bar, which shows the path already highlighted. I can then right click the highlighted path and select Copy.

    It ends up being one more click, but you don't need to hold Shift and it also gets rid of the Quotes.

    Hope this helps.


    Thank You for testing Windows 7

    Ronnie Vernon MVP

    The problem with this is that is only copies the folder path that the file is in not the complete path to the file.  Or am I missing something?
    Monday, October 12, 2009 10:35 PM
  • Not sure why my replies did not get added to the end of the thread but see above to see them please.  Thank you.

    Monday, October 12, 2009 10:45 PM
  • Brian,

    I removed the quotes around %1 and it still inserts quotation marks.  I then close the regedit.  It seems to save.  Are any other steps necessary?

    Thanks,
    Ethan
    Friday, December 4, 2009 2:54 AM
  • The best solution I've found to get the same functionality on the main right-click menu is through the use of the freeware program "Send To Toys" by Gabriele Ponti: http://www.gabrieleponti.com/software/

    This program works great in both Windows 7 and Vista and provides some handy configurability, like for example the ability to use quotes around paths to folders with spaces in them.



    Note that you don't have to install all the toys.

    -Noel





    • Proposed as answer by Noel Carboni Friday, December 4, 2009 4:41 AM
    • Marked as answer by Ronnie VernonMVP Saturday, December 5, 2009 7:44 AM
    Friday, December 4, 2009 4:40 AM
  • Here's the solution I've ended up using which works pretty well for me and doesn't flash any command prompt windows:

    I created a small script using the Autohotkey (www.autohotkey.com) scripting language which just copies any argument passed to it to the clipboard. I then added the appropriate registry entries to add the commands to the right-click menu and pass the path as an argument to the sript.

    Here's the script file contents:
    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    #NoTrayIcon
    
    clipboard=%1%
    
    and a sample registry file:

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\*\shell\Copy Path\command]
    @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"D:\\Documents\\autohotkey\\Copy Path.ahk\" \"%1\""
    
    [HKEY_CLASSES_ROOT\*\shell\Copy Path ""\command]
    @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"D:\\Documents\\autohotkey\\Copy Path.ahk\" \\\"\"%1\"\\\""
    
    [HKEY_CLASSES_ROOT\Folder\shell\Copy Path\command]
    @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"D:\\Documents\\autohotkey\\Copy Path.ahk\" \"%1\""
    
    [HKEY_CLASSES_ROOT\Folder\shell\Copy Path ""\command]
    @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"D:\\Documents\\autohotkey\\Copy Path.ahk\" \\\"\"%1\"\\\""
    You'd have to edit the registry file as appropriate for your needs/file location.

    I've uploaded a zip file with the script and .reg file as well as a compiled version of the script that you can use if you don't want to install Autohotkey on your system. Here's a link to the file:
    http://www.box.net/shared/p6dot70fjf
    • Marked as answer by Magritte Saturday, December 5, 2009 7:32 PM
    Saturday, December 5, 2009 7:29 PM
  • As hinted at in other answers, you can copy without quotes using clip.exe, which is part of windows.  Just add the following registry keys/values (the hex string translates to "%comspec% /c echo %1|clip.exe" (without quotes)):

    [HKEY_CLASSES_ROOT\AllFilesystemObjects\shell]

    [HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\CopyPath]
    @="Copy Path"

    [HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\CopyPath\command]
    @=hex(2):25,00,63,00,6f,00,6d,00,73,00,70,00,65,00,63,00,25,00,20,00,2f,00,63,\
      00,20,00,65,00,63,00,68,00,6f,00,20,00,25,00,31,00,7c,00,63,00,6c,00,69,00,\
      70,00,2e,00,65,00,78,00,65,00,00,00

    • Proposed as answer by C5r1a5z0y Tuesday, December 17, 2013 11:35 PM
    Tuesday, December 17, 2013 11:31 PM
  • This is ridiculous. Because of quotes MS explorer pass to clipboard something it can't take itself. Quotes make it start IE.
    Tuesday, November 28, 2017 9:41 PM