title: How can I use command line arguments to control a batch program that prints multi-colour text?
body: <p>I have a batch script that can display two or more colors of text on the same line in the command prompt. (below)</p>
  
  <pre><code>@echo off
  SETLOCAL EnableDelayedExpansion
  for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# &amp; echo on &amp; for %%b in (1) do rem"') do (
  set "DEL=%%a"
  )
  echo say the name of the colors, don't read
  
  call :ColorText 0a "blue"
  call :ColorText 0C "green"
  call :ColorText 0b "red"
  echo(
  call :ColorText 19 "yellow"
  call :ColorText 2F "black"
  call :ColorText 4e "white"
  pause
  goto :eof
  
  :ColorText
  echo off
  &lt;nul set /p ".=%DEL%" &gt; "%~2"
  findstr /v /a:%1 /R "^$" "%~2" nul
  del "%~2" &gt; nul 2&gt;&amp;1
  goto :eof
  </code></pre>
  
  <p>however that text must be entered in the script before-hand by editing the batch file with notepad. i'd like to be able to just open the command prompt and type something like: </p>
  
  <pre><code>cecho /blue hello world!
  </code></pre>
  
  <p>or</p>
  
  <pre><code>cecho blue "hello world!"
  </code></pre>
  
  <p>or something simple where i can supply the color (preferably as a string not a color code) and text (with or without quotations).</p>
  
  <hr>
  
  <p>I don't know if this is of any use to you but it is possible to save this part of the script:</p>
  
  <pre><code>echo off
  &lt;nul set /p ".=%DEL%" &gt; "%~2"
  findstr /v /a:%1 /R "^$" "%~2" nul
  del "%~2" &gt; nul 2&gt;&amp;1
  goto :eof
  </code></pre>
  
  <p>(from ":ColorText" to the end of the script)
  and save it as "ColorText.bat" in "C:\windows\system32". Then in the other half of the script, everywhere you see:</p>
  
  <pre><code>call :ColorText
  </code></pre>
  
  <p>Change it to:</p>
  
  <pre><code>call ColorText
  </code></pre>
  
  <p>(Omit the colons)
  And save that script as colors.bat in "C:\windows\system32". Then open the command prompt and type "colors". This is how i want it to function; no additional commands, setup scripts, file paths; just a simple one or two word function with all that messy code going on in the background (out of sight). However the above idea still won't let me specify my own text or color from the command prompt.... any ideas?</p>