【问题标题】:windows batch file scripting - keep formatting in htmlwindows批处理文件脚本 - 保持html格式
【发布时间】:2013-03-18 12:42:50
【问题描述】:

我目前正在尝试编写一个简单的批处理脚本,它将运行一系列 windows 命令并将它们很好地输出到单个 html 文件中。

例如,我正在运行的命令是netsh firewall show config,看起来像这样:

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

注意到使用的漂亮间距使其易于查看吗?

我试图将它保存在我创建的 HTML 文件中。到目前为止,我有一个简单的批处理脚本如下:

@echo off

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

当它假脱机到 index.html 文件时,结果输出如下所示:

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

那么有谁知道我可以如何以一种很好的方式输出命令,以便保留格式?它实际上只是一堆空格和中断。

提前感谢您的帮助!

【问题讨论】:

  • 你考虑过使用
     吗?

标签: html scripting batch-file cmd


【解决方案1】:

使用&lt;pre&gt;标签保留文本布局:

@echo off
echo ^<pre^> >>index.html
netsh firewall show config >> index.html
echo ^</pre^> >>index.html

【讨论】:

    猜你喜欢
    • 2013-11-04
    • 1970-01-01
    • 1970-01-01
    • 2011-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    相关资源
    最近更新 更多