Your batch file doesn't magically know which lines you want in the VBScript. Either redirect each echo
output (as agriffaut suggested), or run the echo
statements in a command block and redirect the entire output of that block (so you don't have to append repeatedly):
(
echo MsgBox("Hello"^)
echo Do
echo MsgBox("Hello"^)
echo Loop
)>msg2.vbs
Note that for the latter you need to escape closing parentheses inside the block. In this particular case you could just remove them entirely, though:
(
echo MsgBox "Hello"
echo Do
echo MsgBox "Hello"
echo Loop
)>msg2.vbs
Another option would be using a single echo
statement and escaping the line breaks:
>msg2.vbs echo MsgBox "Hello"^
Do^
MsgBox "Hello"^
Loop
Note that the blank lines are required here.