3

I'm currently trying to write a simple batch script that will run a series of windows commands and output them nicely into a single html file.

the command im running for example, is netsh firewall show config, Looks something like this:

Domain profile configuration (current):
-------------------------------------------------------------------
Operational mode                  = Enable
Exception mode                    = Enable
Multicast/broadcast response mode = Enable
Notification mode                 = Enable
Service configuration for Domain profile:
Mode     Customized  Name

Notice the nice spacing used that makes it easy to see?

I'm trying to keep that in the HTML file that i create. So far, i have a simple batch script as follows:

@echo off

echo ^<font face="courier new" size="2"^>^ >>index.html
netsh firewall show config >> netsh
type netsh >>index.html

When that spools to an index.html file, the resultant output looks something like this:

Domain profile configuration (current): -----------------------------------------------       
 -------------------- Operational mode = Enable Exception mode = Enable
 Multicast/broadcast     response mode = Enable Notification mode = Enable Service
 configuration for Domain profile: Mode Customized Name ------------------------------
------------------------------------ Enable No File and Printer Sharing Allowed\
programs configuration for Domain profile: Mode Traffic

So does anyone know how i can output the command in a nice way, such that the formatting is kept? Its really just a bunch of spaces and breaks.

Appreciate your help in advance!

1
  • have you considered using <pre /> ? Commented Mar 28, 2013 at 6:42

1 Answer 1

3

Use the <pre> tag to retain the text layout:

@echo off
echo ^<pre^> >>index.html
netsh firewall show config >> index.html
echo ^</pre^> >>index.html
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.