# Outputting bold/coloured text in .html file from batch file



## Howonearth (Apr 26, 2012)

Further to earlier post, I'm now trying to get a batch file to output some text into an html file. This was straightforward, but now I'm trying to format the text in the .html file from within the batch file, and I'm struggling...

I'm trying to get the text "Logged Off" to display in bold red.

...trying but failing.

The closest I've got to is this:

rem log last user
echo %username% "LOGGED OFF" %computername% at %time% > \\address\%computername%.html

...but it displays it like this:

user "LOGGED OFF" computer1 at [time]

...and I don't want the quotes (and would like "LOGGED OFF" to be in bold too).

Also, finally (!) does anyone know how I would also get this batch file to output this text to a log file (.txt) and appends information to the file as users log off?
So, I'd end up with a text file which looks something like:

user1 LOGGED OFF computer1 at 12:01
user2 LOGGED OFF computer1 at 12:02
user3 LOGGED OFF computer1 at 12:04

etc...

Thanks in advance for your help.

N


----------



## Howonearth (Apr 26, 2012)

...update...

I've worked-out the second bit...
Just needed to add another line which used >> to output to a .txt file

i.e.
echo %username% logged off %computername% at %time% >> filename.txt

Still stuck on the bold red though...


----------



## Squashman (Apr 4, 2003)

Well using the redirection symbols ">" to output to a file should tell you something. That symbol is a reserved character and when a batch file sees it it is going to think you are redirecting standard output to a file. The same goes for "<". That is also a special character. So any time you have a special character that you need to output to another file you need to escape it with the carrot "^" character.


----------

