Link to home
Start Free TrialLog in
Avatar of Valery Mayer
Valery Mayer

asked on

simple small DOS batch file

I would like a batch file to copy, lets say the word : magic.  After I double click on the batch file on my desktop, all I need to do is CTRL V anywhere for the word "magic" to be typed out.

Anyone knows how to do this?  Please assist.

Thank you !
Avatar of CES
CES

This will take the "texttosave" portion and store it in the clipboard so that you can crtl+V somewhere else

C:\>echo|set/p=texttosave|clip
I believe all you need to do is echo magic| clip

This puts the word magic into the clipboard and you can paste it anywhere.

This way will add a new line at the end so if you don't want that then you'll need to do something like this.

echo|set /p=magic|clip
Avatar of Valery Mayer

ASKER

Sounds great to try out - can you please provide me with the previous steps that would insert the command into a double click shortcut on my desktop ?

THANK YOU
save the following line as a text document on your desktop:

C:\>echo|set/p=magic|clip


then change the extension (right click > rename) from .txt to .bat

Then you will be able to double click
forgot:  I have Windows 10.
save

echo|set /p=magic|clip

to a text file and name it magic.bat. Just as CES IT said but don't have the C:\> in there.
You should use
@set /p=magic<nul|clip

Open in new window

or
@echo.|set /p=magic|clip

Open in new window

The above posted works, but is not correct. echo without anything creates some unwanted but dismissed output.
Mmm does not work.  What I did:

1-  Opened Word 2016
2- Copied/pasted :  C:\>echo|set/p=magic|clip
3- Saved file on desktop as:  test.docx
4- Close the document and the Word software
5- Right clicked on the saved file test.docx and renamed test.bat
6- Double clicked on the renamed file (no error message or other...)
7- Created new email and pressed CTRL V in the text area and got:  C:\>echo|set/p=magic|clip

Help, pls... what am I doing wrong?  TY
get rid of the C:\> so that the only text is :

echo|set/p=magic|clip
ASKER CERTIFIED SOLUTION
Avatar of Sean
Sean
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@echo.|set /p=magic|clip DOES NOT WORK either.  I get @echo.|set /p=magic|clip pasted as if nothing was saved to clipboard (Mmm ??)
As Sean said, redo it using notepad.  I tested myself on a Win 10 machine and this will indeed work.

I opened notepad and saved the following as a .txt file:

echo|set/p=magic|clip

I then renamed the file to have a .bat extension.  Clicking the file briefly opens a cmd window which disappears.  I opened another notepad and did CRTL+V and the word "magic" appears as expected
Used NotePad - renaming the extenton from txt to bat worked!!

Thank you all! :)