Obs.: - This answer is intended for users who want something like this and also no longer want to download string tools.
1) I used this solution in this kind of work, but obviously this is not simple either,
besides the use of external tools available in the system.
2) Basically, use C# code to do the to paste at run time.
The @Narzard comment is 100% correct, I spent a lot of time trying the same as you ask, but I found no solution to do it as simply as possible ... this is the
solution I decided to implement in my Bat code:
@echo off & setlocal EnableDelayedExpansion
set "_out=%temp%\Paste.cs" & set "_csc="%windir%\Microsoft.NET" "csc.exe""
set _arg=/target:exe /out:"!_out:~0,-2!exe" "!_out!" /platform:anycpu & > "!_out!" (
echo/using System^;using System^.Windows^.Forms^;using System^.Threading^;namespace Huddled^{
echo/public class Paste^{[STAThread]static void Main^(^)^{foreach^(string line in Clipboard.GetText^(^).Split^(
echo/new string[]^{"\r\n","\n"^},StringSplitOptions.None^)^)Console.WriteLine^(line^)^;^}^}^})
for /f %%i in ('%__appdir__%\where /r !_csc!')do "%%~i" !_arg! >nul && del /q /f "!_out!" & goto :_next
:_next
for /f tokens^=* %%i in ('"!_out:~0,-2!exe"')do .\executable.exe "%%~i" -a --million "arguments"
del /q /f "!_out:~0,-2!exe" 2>nul & rem: continue from here!
C# without escaping characters tested in .NET Framework x86/x64:
2.0.50727
3.5
4.0.30319
using System;
using System.Windows.Forms;
using System.Threading;
namespace Huddled
{
public class Paste
{
[STAThread] static void Main()
{
foreach(string line in Clipboard.GetText().Split(new string[]{"\r\n","\n"},StringSplitOptions.None))Console.WriteLine(line);
}
}
}
3No way in cmd natively. Need powershell or 3rd party tool unfortunately. You can write to the clipboard with clip.exe but not pull from it – Narzard – 2019-08-12T04:24:12.813