2

I created a context menu in the registry

HKEY_CLASSES_ROOT > * > shell > copy > commmand > cmd /c dir "%1" /b /a:-d /o:n | clip

What this does is copies the file name when I right click on a file, yet I want to add it so it will copy some text before the file name.

so it would be like db.yetteh.co.uk/%1 with %1 being the filename.

cmd /c echo db.yetteh.co.uk & dir  "%1" /b /a:-d /o:n | clip

Any ideas?

1 Answer 1

0

It would be like db.yetteh.co.uk/%1 with %1 being the filename.

Use the following command line:

cmd /c "<nul (set/p _v=db.yetteh.co.uk/) & dir "%1" /b /a:-d /o:n" | clip

Batch file (example.cmd):

cmd /c "<nul (set/p _v=db.yetteh.co.uk/) & dir "%1" /b /a:-d /o:n" | clip

Note:

  • <nul (set/p _v=db.yetteh.co.uk/) is a trick to "echo" text without a trailing <cr><lf>

Usage:

F:\test>example test.cmd

F:\test>cmd /c "<nul (set/p _v=db.yetteh.co.uk/) & dir "test.cmd" /b /a:-d /o:n"   | clip

F:\test>

Clipboard contents:

db.yetteh.co.uk/test.cmd

Further Reading

  • An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
  • dir - Display a list of files and subfolders.
  • echo - Display messages on screen, turn command-echoing on or off.
  • set - Display, set, or remove CMD environment variables. Changes made with SET will remain only for the duration of the current CMD session.

You must log in to answer this question.

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