Jamd
Jamd

Reputation: 97

How do you add text in a Batch File?

I have absolutely no idea how to add text to a batch file. I created a secret file that Shuts down your computer and I really want to know how to add text once you double-click on it!!!! HELP.

Upvotes: 2

Views: 9036

Answers (2)

RATHI
RATHI

Reputation: 5289

You can use this. it will open new cmd window with text you want.

START CMD /C "ECHO Your message && PAUSE"

and if you want a pop up window you can use

mshta javascript:alert("Your message!!");close();

Upvotes: 2

Monika
Monika

Reputation: 2210

You need to use ECHO. Also, put the quotes around the entire file path if it contains spaces.

One other other note, use > to overwrite a file if it exists or create if it does not exist. Use >> to append to an existing file or create if it does not exist.

Overwrite the file with a blank line:

ECHO.>"C:\My folder\Myfile.log"

Append a blank line to a file:

ECHO.>>"C:\My folder\Myfile.log"

Append text to a file:

ECHO Some text>>"C:\My folder\Myfile.log"

Append a variable to a file:

ECHO %MY_VARIABLE%>>"C:\My folder\Myfile.log"

Upvotes: -1

Related Questions