Hide the cmd
window using ShellExecute method. Next registry setting works for a single file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\MyCopyAsPath]
[HKEY_CLASSES_ROOT\*\shell\MyCopyAsPath\command]
@="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
Else
MsgBox "wrong numer of parameters"
End If
Wscript.Quit
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
[HKEY_CLASSES_ROOT\*\shell\CopyAsPathMenu]
"ProgrammaticAccessOnly"="Apartment"
[HKEY_CLASSES_ROOT\*\shell\CopyAsPathMenu\DropTarget]
"CLSID"="{f3d06e7c-1e45-4a26-847e-f9fcdee59be0}"
1Might be suitable for you: hold down the
Shift
key as you right-click the file/folder (or even select), and then chooseCopy As Path
. – JosefZ – 2015-11-30T10:08:31.573Thank 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 – 2015-11-30T10:12:42.027