13

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.

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.

|improve this answer|||||
  • Doesn't work for me. The command prompt just appeared and disappeared. Windows 7 32-bit. – Sun Apr 5 '16 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). – Don't Root here plz... Apr 5 '16 at 16:31
  • Check my solution. It doesn't do the command prompt open-run-vanish trick. – SNag Dec 12 '17 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" – chunk_split May 3 '19 at 20:23
8

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

|improve this answer|||||
  • I can confirm that works on Win 10 Version 1709 64bit – Varun Sharma Apr 14 '18 at 22:34
  • This works still perfectly, no messy popups. – Lassi Kinnunen Jul 9 '19 at 14:08
  • On Windows 7: "This file does not have a program associated with it for performing this action..." – Hashim Oct 1 '19 at 21:30
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.

|improve this answer|||||
  • You are unable to comment on my response? You could have just edited mine. – Don't Root here plz... Apr 5 '16 at 16:33
  • I do not have enough reputation to add a comment unfortunately. – Narzard Apr 5 '16 at 17:19
  • or edit my post? – Don't Root here plz... Apr 5 '16 at 17:29
  • 1
    I've edited Private's post. This post can safely be deleted. – Engineer Toast Apr 6 '16 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 '16 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
|improve this answer|||||
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\")"
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.