This is how to send text to Windows clipboard from within a batch file.
This is particularly useful if you often end up typing or copying the same blocks of text regularly. Once you’ve created the bat files, save them on the desktop and then every time you click on one Windows clipboard will have your text ready to paste!
echo off | clip in the following examples just clears the clipboard of any existing text first, it isn’t really necessary but I’ve kept it in as if you have any issues writing your batch / echo lines, you will at least know that the clipboard will be empty.
echo off | clip echo This text will now be ready to paste when you run this bat| clip
If you have several lines of text, then you’ll need to wrap then in brackets ()
echo off | clip ( echo This is line one echo This is line two echo this is line three )| clip
If you need blank lines and want to get rid of Windows newline after each line of text then do the following.
echo off | clip ( echo.|set /P=This is the first text line. echo. echo. echo.|set /P This is the second text line. echo. echo. echo.|set /P This is the third text line )| clip
What if i want to copy to clipboard each argument passed to the script. Each one in a different line. Can you do this?
Gordon, can you elaborate a little or provide an example of what you are wanting to achieve?
This was much simpler than I had thought and what the other websites had shown. Much thanks!