I have a tool that I added to the shell subkey of the any-file key under HKEY_CLASSES_ROOT so that it appears in the right click menu of any file (also have this in directory menu).

@="Path -> Clipboard"

@="C:\\Program Files (x86)\\PathToClipboard.exe %1"

The tool does nothing more than copying the given parameter (the filepath) to the clipboard.

This worked for ages at least since Win ME (may have recompiled since then). It also kind of works for win-7 but with some quirks: If the file path does contain spaces or any other non alphanumeric characters it is shortened to the DOS compatibility Name.

For example: C:\PROGRA~2\PATHTO~1.EXE

Is there a way around this?

If i put "around the %1the path is correct but windows also passes the " to the program (that i have not touched quite a while. sure i could solve this in the tool, but i wonder if the crude behavior could be fixed on windows side).

  • Have you tried "C:\Program Files (x86)\PathToClipboard.exe" "%1"? note the extra "s and removed backslashes.
    – DavidPostill
    Feb 16, 2016 at 13:59
  • @DavidPostill you can not remove the doubled backslashes from the reg-file. in the registry of course they are single. but putting the program path between " solves the issue! the %1 soes not have to be between quotes marks, otherwise the copied path will be also have quotes. If you post this as an answer i will accept it - Thank you! your second suggestion feels some kind of brutal - I do not know if it breaks other stuff. Feb 17, 2016 at 10:11
  • Great that you have it working. Answer added ;)
    – DavidPostill
    Feb 17, 2016 at 10:40

1 Answer 1


If the program name contains spaces or other non alphanumeric characters it is shortened to the DOS compatibility Name.

@="C:\\Program Files (x86)\\PathToClipboard.exe %1"

The quotes should be around the individual parts, not the complete string.

In this particular case, you should only quote the first part (program name) and the whole string:

@="\"C:\\Program Files (x86)\\PathToClipboard.exe\" %1"


  • \ is used to escape the inner quotes (those around the program name)
  • If you also quote the %1 (the filepath) it will add the quotes when the filepath is passed to the program, so don't quote this part.
  • the correct reg-file-export string would look like: @="\"C:\\Program Files (x86)\\PathToClipboard.exe\" %1" in regedit.exe it would show up as "C:\Program Files (x86)\PathToClipboard.exe" %1 the quote marks around the whole expression (and the escaping within it) behind the @= are mandatory otherwise regedit would deliver a parse error on reading the .regfile Feb 17, 2016 at 11:10
  • Ah. OK. Answer updated.
    – DavidPostill
    Feb 17, 2016 at 11:26
  • i initially used the .reg-File export format because i thought it would be nice format for exactly defining the structure of the values and paths (better than writing a String-Value of the default value under the key XY) but now I am thinking that I added confusion about the actual value (in terms of that is shown in and pasted into regedit.exe) Feb 17, 2016 at 15:19
  • @vlad_tepesch I think everything is clear as it is now ;)
    – DavidPostill
    Feb 17, 2016 at 15:32

You must log in to answer this question.

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