I've created a shortcut to the contextmenu by adding a new registryentry with this RE_SZ Key: cmd.exe start /min /c echo %1|clip

This allows me to copy the path of the rightclicked file.

BUT: It will always open a cmd window for a short time.

How can I hide this cmd window?

  • 1
    Might be suitable for you: hold down the Shift key as you right-click the file/folder (or even select), and then choose Copy As Path.
    – JosefZ
    Nov 30, 2015 at 10:08
  • Thank you for your reply, but the shortcut should show a special program to send to (kodi) and with the standard "Copy path" menu it won't work. Do you know the Registrykey which stored the Copy as Path context menu? This would be interesting, how that works.
    – Janik H
    Nov 30, 2015 at 10:12

1 Answer 1


Hide the cmd window using ShellExecute method. Next registry setting works for a single file:

Windows Registry Editor Version 5.00


@="wscript D:\\VB_scripts\\SU\\1007076.vbs \"%1\""

where D:\VB_scripts\SU\1007076.vbs reads as follows:

option explicit
On Error GoTo 0

If WScript.Arguments.Count = 1 Then
  Dim objShell
  Set objShell = CreateObject("shell.application")
  objShell.ShellExecute "cmd.exe" _
    , "/C echo(" & WScript.Arguments(0) & "|clip", "", "open", 0
  Set objShell = nothing
  MsgBox "wrong numer of parameters"
End If

Above script returns full path of a single file (or target of a file shortcut) and adds CRLF (carriage return and linefeed). You could omit the CRLF using set /P trick as follows:

  objShell.ShellExecute "cmd.exe" _
    , "/C <NUL set /P =""" & WScript.Arguments(0) & """|clip", "", "open", 0

Next improvement to surround the path in a pair of " double quotes:

  objShell.ShellExecute "cmd.exe" _
    , "/C <NUL set /P =""""" & WScript.Arguments(0) & """""|clip", "", "open", 0

FYI, here is registry key which stored the Copy as Path context menu:

Windows Registry Editor Version 5.00


  • Thank you very much for this! Although I have to create a file (VBScript) but it really works! Great! And also a nice explanation! :)
    – Janik H
    Dec 1, 2015 at 5:02

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.