How To Print a Line without Closing CR\LF in Batch Files

'Echo' is likely the most often used command in the whole batch scripting. The only disadvantage of this command is ending CR\LF that is always being put after the text. Unfortunately, there is no command that can print text without closing CR\LF in the standard set of commands provided by MS. Thus we have to write quite a large amount of code to implement this feature.





















Here is the code:

@ECHO OFF
> #.SCR ECHO N _CHO.COM 
>>#.SCR ECHO E 0100 BB 80 00 43 80 3F 0D 75 FA C6 07 24 B4 09 BA 82 
>>#.SCR ECHO E 0110 00 39 DA 7F 02 CD 21 B4 4C CD 21 
>>#.SCR ECHO RCX 
>>#.SCR ECHO 001B 
>>#.SCR ECHO W 
>>#.SCR ECHO Q 
>>#.SCR ECHO. 
DEBUG<#.SCR>NUL 
DEL #.SCR 
_CHO %DATE% >TEST.TXT
_CHO TEST FIRST WORD >>TEST.TXT
_CHO TEST SECOND WORD >>TEST.TXT


As far as you can see, this code produces a small COM file that is able to print text without closing CR\LFs. Of course, you can easily edit the batch script and rename this COM file from _CHO to any name you prefer. Hope you'll find this post useful.
0 Comments
Disqus
Fb Comments
Comments :

0 comments:

Post a Comment