开发者

Msg * in batch needs new line how?

Im running the following code snipet

Msg * "Hoi %username%, je kunt nu alle vensters sluiten en AutoCAD opniew opstarten"

but i want a new line after %username% how can i achieve this?

EDDIT:

    ECHO PROOF OF FILE EXECUTION: > "%username%'s proof of file execution.txt"
ECHO.

ECHO EXECUTED BY:   %username%      >> "%username%'s proof of file execution.txt"
ECHO ON:        %date%          >> "%username%'s proof of file execution.txt"
ECHO AT:        %time%   开发者_开发技巧       >> "%username%'s proof of file execution.txt"
ECHO .

ECHO PC DETAILS:
ECHO .
ECHO COMPUTER:      %COMPUTERNAME%      >> "%username%'s proof of file execution.txt"

Msg * "Hoi %username% je kunt nu alle vensters sluiten en AutoCAD opniew opstarten" 


The question is, what is "Msg", is it a batch is it an exe file? Does it support a < Linefeed >?

You can try this, perhaps it works.

setlocal EnableDelayedExpansion
set lf=^


rem Two blank lines (without spaces are neccessary)
Msg * "Hoi %username%!lf! je kunt nu alle vensters sluiten en AutoCAD opniew opstarten" 

But if it works, depends of the Msg-Command


@echo off
msg * Hello^

World!^

Bye^

at^

all!

Output:

Hello
World!
Bye
at
all!

With variable:

@echo off
(set msg1=Hello^^^

^

)
msg * %msg1%World!

Output

Hello
World!


Jeb's answer didn't work for me. The linefeed made msg skip all text following it

The solution is to create a template msg.txt file containing the newlines and piping that into msg:

echo Hoi %username% >msg.txt
echo. >>msg.txt
echo je kunt nu alle vensters sluiten en AutoCAD opniew opstarten >>msg.txt

type msg.txt |msg *


All examples presented here are either complex and contain unnecessary code, or they will work with errors. Especially when you want to print many other "ANSI" characters through "Msg".

The code has been tested in many variations. It is simple and works stably:

(echo %str1%&echo %str2%)|msg "%username%" or *

Example: Win+R > cmd /c "@(echo More Strings&echo.&echo For You !)|@msg *"

Result: MsgBox

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜