如何在批处理脚本中打印

How To Print This In A Batch Script

我是 Batch 的新手,我想打印一些东西而不用回显所有内容,即使我尝试使用回显也没有用。可能有一个简单的答案,但请帮忙。

我要打印的内容:

<body>
              _
             /_\
_            )_(            _
|`-.___,.-~'`|=|`'~-.,___,-'|
|  __________|=|__________  |
| |    ______|=|__________| | ___      _      _  _   _             _             
| |   |  ____|=|_____     / |  |  |_| |_  |  |_ | _ |_ |\| |\  /\ |_
| |   | /    |=|    /    /| |  |  | | |_  |_ |_ |_| |_ | | |/  \/ |
| |   |/   ,-|_|-. / /  /_|_|______ ______     _______        ____
| |      ,' _____ / // / \    ___  |\    /     \      `.      \   \
| |     / ,'| _ |/ // /   |  |   \ | |  |       |  |`.  \     /    \
| |    /_// |/V\/ // /    |  |    \| |  |       |  |  \  \   /  /\  \
| |      /__| |/  / /     |  |       |  |       |  |   \  | /  /  \  \
| |     /\  | / /| /\     |  |__/|   |  |       |  |   |  ||  |    |  |
| |    /  \ |/ // // \    |   __ |   |  |       |  |   |  ||  |____|  |
| |   /    \/ |/ //   \   |  |  \|   |  |       |  |   |  ||   ____   |
| |  /     /    //     \  |  |       |  |       |  |   /  ||  |    |  |
| | /     / /  /|       \ |  |    /| |  |    /| |  |  /  / |  |    |  |
| |/_____/ // / |________\|  |___/ | |  |___/ | |  |,'  /  |  |    |  |
| |     / // /| |        /_________|/_________|/______,'  /____\  /____\
\ \    / // / | |       /|/ /
 \ \  /  / /| | |______/ | /
  \ \/______| | |________|/ 
   `.`.     | | |     ,','
     `.`.   | | |   ,','            
       `.`-.| | |,-','     
         `-.| | |,-'        
            | | |    
            | | |   
            | | |   
            | | |   
            | | |   
             \|/                 
              V 
<body>

如果出于某些无法解释的原因,您不想将它保存到另一个文件中,您可以将它包含在脚本本身中:

::    <body>
::                  _
::                 /_\
::    _            )_(            _
::    |`-.___,.-~'`|=|`'~-.,___,-'|
::    |  __________|=|__________  |
::    | |    ______|=|__________| | ___      _      _  _   _             _             
::    | |   |  ____|=|_____     / |  |  |_| |_  |  |_ | _ |_ |\| |\  /\ |_
::    | |   | /    |=|    /    /| |  |  | | |_  |_ |_ |_| |_ | | |/  \/ |
::    | |   |/   ,-|_|-. / /  /_|_|______ ______     _______        ____
::    | |      ,' _____ / // / \    ___  |\    /     \      `.      \   \
::    | |     / ,'| _ |/ // /   |  |   \ | |  |       |  |`.  \     /    \
::    | |    /_// |/V\/ // /    |  |    \| |  |       |  |  \  \   /  /\  \
::    | |      /__| |/  / /     |  |       |  |       |  |   \  | /  /  \  \
::    | |     /\  | / /| /\     |  |__/|   |  |       |  |   |  ||  |    |  |
::    | |    /  \ |/ // // \    |   __ |   |  |       |  |   |  ||  |____|  |
::    | |   /    \/ |/ //   \   |  |  \|   |  |       |  |   |  ||   ____   |
::    | |  /     /    //     \  |  |       |  |       |  |   /  ||  |    |  |
::    | | /     / /  /|       \ |  |    /| |  |    /| |  |  /  / |  |    |  |
::    | |/_____/ // / |________\|  |___/ | |  |___/ | |  |,'  /  |  |    |  |
::    | |     / // /| |        /_________|/_________|/______,'  /____\  /____\
::    \ \    / // / | |       /|/ /
::     \ \  /  / /| | |______/ | /
::      \ \/______| | |________|/ 
::       `.`.     | | |     ,','
::         `.`.   | | |   ,','            
::           `.`-.| | |,-','     
::             `-.| | |,-'        
::                | | |    
::                | | |   
::                | | |   
::                | | |   
::                | | |   
::                 \|/                 
::                  V 
::    <body>
@Echo Off
SetLocal EnableExtensions
For /F "Tokens=1,* Delims=:" %%G In ('%SystemRoot%\System32\findstr.exe "^::" "%~f0"') Do Echo %%G
Pause

您可以使用 echo,但由于涉及特殊字符,您需要将这些行用双引号引起来,或者对每个特殊字符进行转义。然后,您可以使用 type 来实现这一点,如 @Squashman 的评论中所示。 但是,如果你有 Windows 10 OS(或 Windows 11),你可以做到 使用 ANSI 转义码更有趣。

这是一个例子,现在看起来不太像,但只需按原样将其保存到扩展名为 .cmd 且 运行 的文件中:

@echo off
for /F %%i in ('echo prompt $E ^| cmd') do set "e=%%i"
mode con cols=100 lines=40
echo(
echo(
echo %e%[30m"        %e%[93m              _                                                 %e%[30m"
echo %e%[30m"        %e%[93m             /_\                                                    %e%[30m"
echo %e%[30m"        %e%[93m             )_(                                                        %e%[30m"
echo %e%[30m"        %e%[32m|`-.___,.-~'`%e%[93m|=|%e%[32m`'~-.,___,-'|                                     %e%[30m"
echo %e%[30m"        %e%[32m|  __________%e%[93m|=|%e%[32m__________  |                                     %e%[30m"
echo %e%[30m"        %e%[32m| |   %e%[31m ______%e%[93m|=|%e%[31m__________%e%[32m| | %e%[34m___      _      _  _   _             _     %e%[30m"
echo %e%[30m"        %e%[32m| |   %e%[31m|  ____%e%[93m|=|%e%[31m_____     /%e%[32m | %e%[34m |  |_| |_  |  |_ | _ |_ |\| |\  /\ |_     %e%[30m"
echo %e%[30m"        %e%[32m| |   %e%[31m| /    %e%[93m|=|%e%[31m    /    /%e%[32m| | %e%[34m |  | | |_  |_ |_ |_| |_ | | |/  \/ |      %e%[30m"
echo %e%[30m"        %e%[32m| |   %e%[31m|/   %e%[93m,-|_|-.%e%[31m / /  /_%e%[32m|%e%[31m_%e%[32m|%e%[31m______ ______     _______        ____ %e%[30m"
echo %e%[30m"        %e%[32m| |      %e%[93m,' _____%e%[31m / // / \    ___  |\    /     \      `.      \   \                   %e%[30m"
echo %e%[30m"        %e%[32m| |     %e%[93m/ ,'| _ |%e%[31m/ // /   |  |   \ | |  |       |  |`.  \     /    \                  %e%[30m"
echo %e%[30m"        %e%[32m| |   %e%[93m /_/%e%[32m/ %e%[93m|/V\%e%[31m/ // /    |  |    \| |  |       |  |  \  \   /  /\  \           %e%[30m"
echo %e%[30m"        %e%[32m| |      /__%e%[93m| |%e%[31m/  / /     |  |       |  |       |  |   \  | /  /  \  \                %e%[30m"
echo %e%[30m"        %e%[32m| |     /\  %e%[93m| %e%[31m/ /| /%e%[32m\%e%[31m     |  |__/|   |  |       |  |   |  ||  |    |  |         %e%[30m"
echo %e%[30m"        %e%[32m| |    /  \ %e%[93m|%e%[31m/ // // %e%[32m\%e%[31m    |   __ |   |  |       |  |   |  ||  |____|  |         %e%[30m"
echo %e%[30m"        %e%[32m| |   /    \%e%[31m/ |/ //   %e%[32m\%e%[31m   |  |  \|   |  |       |  |   |  ||   ____   |            %e%[30m"
echo %e%[30m"        %e%[32m| |  /     %e%[31m/    //%e%[32m     \  %e%[31m|  |       |  |       |  |   /  ||  |    |  |            %e%[30m"
echo %e%[30m"        %e%[32m| | /     %e%[31m/ /  /%e%[93m|%e%[32m       \%e%[31m |  |    /| |  |    /| |  |  /  / |  |    |  |         %e%[30m"
echo %e%[30m"        %e%[32m| |/_____%e%[31m/ // / %e%[93m|%e%[32m________\%e%[32m|  |___/ | |  |___/ | |  |,'  /  |  |    |  |         %e%[30m"
echo %e%[30m"        %e%[32m| |     %e%[31m/ // /%e%[93m| |%e%[31m        /_________|/_________|/______,'  /____\  /____\           %e%[30m"
echo %e%[30m"        %e%[32m\ \    %e%[31m/ // / %e%[93m| |%e%[31m       /|%e%[32m/ /                               %e%[30m"
echo %e%[30m"        %e%[32m \ \  %e%[31m/  / /%e%[93m| | |%e%[31m______/ |%e%[32m /                                %e%[30m"
echo %e%[30m"        %e%[32m  \ \%e%[31m/______%e%[93m| | |%e%[31m________|%e%[32m/                                 %e%[30m"
echo %e%[30m"        %e%[32m   `.`.     %e%[93m| | |%e%[32m     ,','                                        %e%[30m"
echo %e%[30m"        %e%[32m     `.`.   %e%[93m| | |%e%[32m   ,','                                              %e%[30m"
echo %e%[30m"        %e%[32m       `.`-.%e%[93m| | |%e%[32m,-','                                            %e%[30m"
echo %e%[30m"        %e%[32m         `-.%e%[93m| | |%e%[32m,-'                                              %e%[30m"
echo %e%[30m"        %e%[91m            %e%[93m| | |                                                %e%[30m"
echo %e%[30m"        %e%[91m            %e%[93m| | |                                                %e%[30m"
echo %e%[30m"        %e%[91m            %e%[93m| | |                                                %e%[30m"
echo %e%[30m"        %e%[91m            %e%[93m| | |                                                %e%[30m"
echo %e%[30m"        %e%[91m            %e%[93m| | |                                                %e%[30m"
echo %e%[30m"        %e%[91m             %e%[93m\|/                                                         %e%[30m"
echo %e%[30m"        %e%[91m              %e%[93mV                                              %e%[30m"
echo %e%[0m
pause>nul

结果: