18

If I hold shift when opening the Windows Explorer context menu, an extra item appears, 'copy as path'. How can I make it so it always appears without having to hold shift?

I'm using Windows 10.

4

5 Answers 5

15

This script works (tested on Windows 10) without invoking command prompt:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Allfilesystemobjects\shell\windows.copyaspath]
@="Copy &as path"
"Icon"="imageres.dll,-5302"
"InvokeCommandOnSelection"=dword:00000001
"VerbHandler"="{f3d06e7c-1e45-4a26-847e-f9fcdee59be0}"
"VerbName"="copyaspath"

It also assigns a as the hotkey on the context menu, so RightClick+a copies the file path.

Bonus: Script to remove the above setting:

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Allfilesystemobjects\shell\windows.copyaspath]

Script Credits

Screenshot from Windows 10 Enterprise v1809 build 17763.437: Copy as Path

4
  • 1
    I can confirm that works on Win 10 Version 1709 64bit Apr 14, 2018 at 22:34
  • This works still perfectly, no messy popups. Jul 9, 2019 at 14:08
  • On Windows 7: "This file does not have a program associated with it for performing this action..." Oct 1, 2019 at 21:30
  • Worked fine for me, too. Also, the icon is a nice addition :-) Just a hint: the position in the context menu is different from the entry that appears when you use Shift + Right click - it appears close to the top. - I just noticed that you showed that on the screenshot @snag but I didn't look at that :-D
    – Oliver
    Jan 18, 2021 at 9:17
10
+25

AskVG here has a perfect solution. Though it says Windows 7, I've tried it on my Windows 10 PC and it works.

You can download the registry script straightaway from here. I've tested it and it contains no malicious code.


To prevent link rot, here are the contents of the REG file. Save the following as copyaspath.reg and then double-click to run.

Windows Registry Editor Version 5.00

;Created by Vishal Gupta for AskVG.com

[HKEY_CLASSES_ROOT\*\shell\Copy as Path]

[HKEY_CLASSES_ROOT\*\shell\Copy as Path\command]
@="cmd.exe /c echo | set /p=\"\"%1\"\"|clip"

[HKEY_CLASSES_ROOT\Directory\shell\Copy as Path]

[HKEY_CLASSES_ROOT\Directory\shell\Copy as Path\command]
@="cmd.exe /c echo | set /p=\"\"%1\"\"|clip"

Kudos to @chunk_split for a workaround to remove the newline.

4
  • Doesn't work for me. The command prompt just appeared and disappeared. Windows 7 32-bit.
    – Sun
    Apr 5, 2016 at 15:23
  • @sunk818 Yeah, according to the comments, this doesn't work on Windows Xp or 7 but works on Windows 10. Don't know what the problem is but it works on my computer :) (Windows 10 ver1511). Apr 5, 2016 at 16:31
  • Check my solution. It doesn't do the command prompt open-run-vanish trick.
    – SNag
    Dec 12, 2017 at 20:01
  • This works very well, except it introduces an extra newline at the end (due to how echo works). You can use the following workaround to avoid that. Note the extra escaped quotes, escaped 2x, first time using backslashes for Windows Registry file format to get "" needed for the set /p command resulting in finally a single " in your copied string, so the full line becomes: @="cmd.exe /c echo | set /p=\"\"%1\"\"|clip" May 3, 2019 at 20:23
1

I am unable to comment on user Private's response but this looks correct. Here are the registry entries needed from the file he linked.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Copy as Path]

[HKEY_CLASSES_ROOT\*\shell\Copy as Path\command]
@="cmd.exe /c echo \"%1\"|clip"

[HKEY_CLASSES_ROOT\Directory\shell\Copy as Path]

[HKEY_CLASSES_ROOT\Directory\shell\Copy as Path\command]
@="cmd.exe /c echo \"%1\"|clip"

You can just save that as a .reg and run it.

6
  • You are unable to comment on my response? You could have just edited mine. Apr 5, 2016 at 16:33
  • I do not have enough reputation to add a comment unfortunately.
    – Narzard
    Apr 5, 2016 at 17:19
  • or edit my post? Apr 5, 2016 at 17:29
  • 1
    I've edited Private's post. This post can safely be deleted. Apr 6, 2016 at 21:14
  • 1
    @EngineerToast: I wouldn't count it as safe unless there's some record of Narzard's involvement on that question ;)
    – SamB
    Oct 5, 2016 at 20:08
0

Here is the REG file:

Windows Registry Editor Version 5.00

[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,3c,00,6e,00,75,00,6c,00,20,00,28,00,73,00,65,00,74,00,2f,00,70,00,\
  20,00,61,00,6e,00,79,00,76,00,61,00,72,00,69,00,61,00,62,00,6c,00,65,00,3d,\
  00,22,00,25,00,31,00,22,00,29,00,7c,00,63,00,6c,00,69,00,70,00,2e,00,65,00,\
  78,00,65,00,00,00

(via Winhelponline) I removed the "Extended" string value.

The hex code in the above REG file translates to this command-line:

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

Well, SNag's answer is most elegant.

Don't Root's answer works, but you may see a balck CMD window flash quickly sometimes, and it does not support non-English characters. Here's an improved version from 1ocalhost.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Copy Path\command]
@="mshta vbscript:CreateObject(\"wscript.shell\").Run(\"cmd /c chcp 65001 && echo | set /p x=\"\"%1\"\" | clip\",0)(window.close)"

Because there's no clip.exe in Windows XP by default, 1ocalhost also provide another version for Windows XP:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Copy Path\command]
@="mshta vbscript:Execute(\"set o=CreateObject(\"\"InternetExplorer.Application\"\")\"&vbcrlf&\"o.Navigate(\"\"about:blank\"\")\"&vbcrlf&\"o.document.parentwindow.clipboardData.setData \"\"text\"\", \"\"%1\"\"\"&vbcrlf&\"o.Quit\"&vbcrlf&\"window.close\")"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .