JSI Tip 10147. How can my batch script place text in the Clipboard?

Jerold Schulman

February 9, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today


I have scripted PasteClipBoard.bat to paste a text string to the Clipboard.

The syntax for using PasteClipBoard.bat is:

[Call] PasteClipBoard Content

Where Content is the string you want to paste.

Examples:

PasteClipBoard Hello

PasteClipBoard "Hello world"

PasteClipBoard.bat contains:

@echo offif {%1}=={} @echo Syntax: PasteClipBoard content&goto :EOFif exist "%TEMP%PasteClipBoard.vbs" goto doit@echo Dim objArgs>"%TEMP%PasteClipBoard.vbs"@echo Set objArgs = Wscript.Arguments>>"%TEMP%PasteClipBoard.vbs"@echo Content = objArgs(0)>>"%TEMP%PasteClipBoard.vbs"@echo Set objIE = CreateObject("InternetExplorer.Application")>>"%TEMP%PasteClipBoard.vbs"@echo objIE.Navigate("about:blank")>>"%TEMP%PasteClipBoard.vbs"@echo objIE.document.parentwindow.clipboardData.SetData "text", Content>>"%TEMP%PasteClipBoard.vbs"@echo objIE.Quit>>"%TEMP%PasteClipBoard.vbs":doitcscript //nologo "%TEMP%PasteClipBoard.vbs" %1



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like