With a suitable external program, yes. Try e.g.
2955 Jan 15 2001 ftp://garbo.uwasa.fi/pc/sysutil/wclip22.zip
wclip22.zip Clipboard Utility for MS-DOS, freeware, H.Schaeffer, nice
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful batch files and tricks ftp://garbo.uwasa.fi/pc/link/tsbat.zip
Yes, easily.
> What I need is for a batch file be able to paste some text from the
> clipboard into a text file.
This is quite easy with the SendKeys function of WSH (Windows
Script Host). WSH has a Batch interface CSCRIPT.EXE designed
exactly for this sort of thing:
====Begin cut-and-paste (omit this line)
@ECHO OFF
:: Open a blank new file
REM New file>CLIP.TXT
ECHO.set sh=WScript.CreateObject("WScript.Shell")>{TEMP}.VBS
ECHO.sh.Run("Notepad.exe CLIP.TXT")>>{TEMP}.VBS
ECHO.WScript.Sleep(200)>>{TEMP}.VBS
ECHO.sh.SendKeys("^+{end}^{v}%%{F4}{enter}{enter}")>>{TEMP}.VBS
cscript//nologo {TEMP}.VBS
ECHO. The clipboard contents are:
TYPE CLIP.TXT
:: Clean up
FOR %%F IN ({TEMP}.VBS CLIP.TXT) DO DEL %%F
====End cut-and-paste (omit this line)
Win9x GUI study/demo only. Cut-and-paste as Batch script (file with .BAT
extension). Lines that don't begin with 2 spaces have wrapped by mistake.
Requires WSH (Windows Script Host - see Note 1)
> Also I need it to be able to put
> something into the clipboard for use by other programs.
> Is it something as easy as a variable?
You can download the Microsoft Win95 Resource Kit
Batch utility CLIP.EXE free from:
ftp://ftp.microsoft.com/Services/TechNet/samples/ps/win98/reskit/file/
and click on CLIP.EXE
============Screen capture Windows 95
C:\WORK>clip /?
Clip version 1.1. Copyright 1997 Microsoft Corporation.
Command-line output redirector.
Clip.exe redirects command-line output to the Windows Clipboard.
Examples:
---------
dir | clip
Places a copy of the current directory listing into the Windows clipboard.
clip < readme.txt
Places a copy of the text from readme.txt into the Windows clipboard.
C:\WORK>
============End screen capture
--
(pp) William Allen
Note 1:
WSH (Windows Script Host) is available as a free downloadable
add-on for the tiny proportion of Windows machines (mostly older
Windows 95 ones) which don't already have it installed in one
version or another. Current version (around 5.6-ish) will install
on Windows 95 machines as well as Windows 98 and ME. There
is _extremely_ extensive free documentation included for WSH
in the form of HTML help files, which include masses of syntax
examples in VBScript and JScript.
Windows Script Host main page for information and downloads:
http://msdn.microsoft.com/scripting/
By default, WSH installs CSCRIPT.EXE which is a Batch file
interface allowing all WSH functionality to be run from a normal
DOS-style Batch file. This interface provides Windows machines
with an enormous extension to the traditional Batch functionality.
Note:
WSH (Windows Script Host) is available as a free downloadable
add-on for the tiny proportion of Windows machines (mostly older
Windows 95 ones) which don't already have it installed in one
version or another. Current version (around 5.6-ish) will install
on Windows 95 machines as well as Windows 98 and ME. There
is _extremely_ extensive free documentation included for WSH
in the form of HTML help files, which include masses of syntax
examples in VBScript and JScript.
Windows Script Host main page (for information and free downloads):
http://msdn.microsoft.com/scripting/
By default, WSH installs CSCRIPT.EXE which is a Batch file
interface allowing all WSH functionality to be run from a normal
MS-DOS Batch file. This interface provides Windows machines
with an enormous extension to the traditional Batch functionality.
and implements a number of Batch-specific extensions, including:
a) Run time error messages filterable with FIND command
b) ERRORLEVEL 1 returned to parent Batch file if WSH script not found
c) Access to Standard command-line input/output/error channels
wscript.echo - extended form of ECHO (also redirectable to files),
that, for example, handles strings and general arithmetic, eg:
wscript.echo "SET PRODUCT="& %FirstNum%*%SecondNum%
writes a line that will set PRODUCT equal to the numeric product.
wscript.stdout - direct access to STDOUT, similar to ECHO, but
handles wider range of characters, and can write lines
without any terminating CR/LF characters.
wscript.stdin - direct access to STDIN
wscript.stderr - direct access to STDERR
One of the more obscure features of 4DOS is that it allows access
to the Windows clipboard as a character device named CLIP: This
provides a nifty way to create a sort of temp file, only with no
disk access and no directory entry:
@echo off
dir /a-d-h-s /b > clip:
set ds=%_year-%@format[02,%_month]-%@format[02,%_day]
for %f in ( @clip: ) do ren "%f" "%@name[%f] %ds.%@ext[%f]"
set ds=
Of course this feature only works under Windows, not in plain
vanilla DOS. Unfortunately, Microsoft's command shells offer
no equivalent. There are, however, freeware utilities which
provide at least some of this functionality to COMMAND.COM.
--
Charles Dye ras...@highfiber.com
Nice, Timo.
I am that some of us still respect that this IS a DOS group
and not a "anything Microsoft" group.
--
Batchman
> I am that some of us still respect that this IS a DOS group
^ happy :)
How about a multi clipboard. Such a thing is something like
99MB, price 999, shareware along with an unstable computer.
MultiClip.bat
@echo off
if exist %TEMP%.\~CLIP.HTM goto write
find.exe "!--% % 0"<%0>>%TEMP%.\~CLIP.HTM
goto Write
<!-- 0--><html>
<!-- 0--><p align=center>
<!-- 1--><textarea rows=4 cols=50 style=scrollbar-track-color:#ffff00>
<!--
</textarea><!-- 2-->
:Write
find.exe "!--% % 1"<%0>>%TEMP%.\~CLIP.HTM
echo> %TEMP%.\~.VBS set sh=WScript.CreateObject("WScript.Shell")
echo>>%TEMP%.\~.VBS sh.Run("%windir%\Notepad.exe %TEMP%.\~CLIP.HTM")
echo>>%TEMP%.\~.VBS WScript.Sleep(40)
echo>>%TEMP%.\~.VBS sh.SendKeys("^{end}^{v}%%{F4}{enter}")
start.exe /min /wait cscript.exe /nologo %TEMP%.\~.VBS
find.exe "!--% % 2"<%0>>%TEMP%.\~CLIP.HTM
start.exe %TEMP%.\~CLIP.HTM
erase %TEMP%.\~.VBS
Benny Pedersen,
PS. I steal some code from William ;*)
BTW. It can be modified with more HTML code that you may found
here: http://2dos.homepage.dk/batutil/GARBAGE.HTM#btw