To echo a text without the writing of the ending newline (like
echo -n under POSIX), type :
echo | set /p="<text>"
<text> is the text to display.
|| trueto reset the errorlevel.
To put the result of a command in an environment variable, type :
<command> > <file> - set /p <variable>= < <file>
<command>is the command from which you want to retrieve the result,
<variable>the name of the environment variable in which you want to store the result of the above command,
<file>: the name of a temporary file which can be deleted afterwards.
The return value of a DOS command can be retrieved through
%ERRORLEVEL%. A value other then
0 usually indicates an error.
Copying to clipboard :
… | clip.
There is a way to copy from clipboard, but it involves PowerShell.
Also see Cygwin section.