Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows批处理系统信息到HTML_Html_Batch File_Operating System_Webpage_System Information - Fatal编程技术网

Windows批处理系统信息到HTML

Windows批处理系统信息到HTML,html,batch-file,operating-system,webpage,system-information,Html,Batch File,Operating System,Webpage,System Information,我正在尝试创建一个批处理文件,该文件将使用systeminfo命令将操作系统、当前登录的域、制造商、计算机模型等内容放入HTML表中。这是我当前批处理文件的内容: @echo off systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"OS Manufacturer" /C:"OS Configuration" /C:"OS Build Type" /C:"Original Install Date" /C:"System Boot

我正在尝试创建一个批处理文件,该文件将使用systeminfo命令将操作系统、当前登录的域、制造商、计算机模型等内容放入HTML表中。这是我当前批处理文件的内容:

@echo off
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"OS Manufacturer" /C:"OS Configuration" /C:"OS Build Type" /C:"Original Install Date" /C:"System Boot Time" /C:"System Manufacturer" /C:"System Model" /C:"System Type" /C:"Processor(s)" /C:"BIOS Version" /C:"Windows Directory" /C:"System Directory" /C:"Boot Device" /C:"System Locale" /C:"Input Locale" /C:"Total Physical Memory" /C:"Available Physical Memory" /C:"Virtual Memory: Max Size" /C:"Virtual Memory: Available" /C:"Virtual Memory: In Use" /C:"Domain" /C:"Network Card(s)"
pause
这是电流输出:

OS Name:                   Microsoft Windows 7 Professional
OS Version:                6.1.7601 Service Pack 1 Build 7601
Original Install Date:     7/26/2011, 1:47:23 AM
System Boot Time:          2/25/2014, 1:39:14 AM
System Manufacturer:       Dell Inc.
System Model:              Inspiron 1501
System Type:               X86-based PC
Processor(s):              1 Processor(s) Installed.
Domain:                    WORKGROUP
Press any key to continue . . .
如何将其放入HTML表中?
任何帮助都将不胜感激!谢谢。

以下内容适合您。乐意提供任何解释

@echo off
(
echo ^<table^>
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"OS Manufacturer" /C:"OS Configuration" /C:"OS Build Type" /C:"Original Install Date" /C:"System Boot Time" /C:"System Manufacturer" /C:"System Model" /C:"System Type" /C:"Processor(s)" /C:"BIOS Version" /C:"Windows Directory" /C:"System Directory" /C:"Boot Device" /C:"System Locale" /C:"Input Locale" /C:"Total Physical Memory" /C:"Available Physical Memory" /C:"Virtual Memory: Max Size" /C:"Virtual Memory: Available" /C:"Virtual Memory: In Use" /C:"Domain" /C:"Network Card(s)">f.txt
for /f "tokens=1* delims=:" %%a in (f.txt) do echo ^<tr^>^<td^>%%a^</td^> ^<td^>%%b^</td^>^</tr^>
echo ^</table^>
) >test.html
@echo关闭
(
回音^
systeminfo | findstr/B/C:“操作系统名称”/C:“操作系统版本”/C:“操作系统制造商”/C:“操作系统构建类型”/C:“原始安装日期”/C:“系统启动时间”/C:“系统制造商”/C:“系统型号”/C:“处理器”/C:“BIOS版本”/C:“Windows目录”/C:“系统目录”/C:“启动设备”/C:“系统区域设置”/C:“输入区域设置”/C:“总物理内存”/C:“可用物理内存”/C:“虚拟内存:最大大小”/C:“虚拟内存:可用”/C:“虚拟内存:正在使用”/C:“域”/C:“网卡”>f.txt
对于/f“tokens=1*delims=:”%(f.txt)中的%%a执行echo^%%a^^%%b^^
回音^
)>test.html

显然,将
>>test.html
更改为您想要输出到的任何文件的名称,我建议最好使用一个变量。您还可能需要删除脚本末尾的
f.txt
。您可以通过将CSS回传到(我使用过的)任何内容来设置样式
test.html

这一切都取决于你想要得到的幻想。最简单的方法是

@echo off
(
echo ^<HTML^> 
echo ^<BODY^> 
echo ^<pre^> 
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"OS Manufacturer" /C:"OS Configuration" /C:"OS Build Type" /C:"Original Install Date" /C:"System Boot Time" /C:"System Manufacturer" /C:"System Model" /C:"System Type" /C:"Processor(s)" /C:"BIOS Version" /C:"Windows Directory" /C:"System Directory" /C:"Boot Device" /C:"System Locale" /C:"Input Locale" /C:"Total Physical Memory" /C:"Available Physical Memory" /C:"Virtual Memory: Max Size" /C:"Virtual Memory: Available" /C:"Virtual Memory: In Use" /C:"Domain" /C:"Network Card(s)"
echo ^</pre^> 
echo ^</BODY^> 
echo ^</HTML^>
)>sysinfo.html
@echo关闭
(
回声^
回声^
回声^
systeminfo | findstr/B/C:“操作系统名称”/C:“操作系统版本”/C:“操作系统制造商”/C:“操作系统构建类型”/C:“原始安装日期”/C:“系统启动时间”/C:“系统制造商”/C:“系统型号”/C:“处理器”/C:“BIOS版本”/C:“Windows目录”/C:“系统目录”/C:“启动设备”/C:“系统区域设置”/C:输入区域设置/C:“总物理内存”/C:“可用物理内存”/C:“虚拟内存:最大大小”/C:“虚拟内存:可用”/C:“虚拟内存:正在使用”/C:“域”/C:“网卡”
回声^
回声^
回音^
)>sysinfo.html
这里有一个CSS格式的表格

@echo off
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"OS Manufacturer" /C:"OS Configuration" /C:"OS Build Type" /C:"Original Install Date" /C:"System Boot Time" /C:"System Manufacturer" /C:"System Model" /C:"System Type" /C:"Processor(s)" /C:"BIOS Version" /C:"Windows Directory" /C:"System Directory" /C:"Boot Device" /C:"System Locale" /C:"Input Locale" /C:"Total Physical Memory" /C:"Available Physical Memory" /C:"Virtual Memory: Max Size" /C:"Virtual Memory: Available" /C:"Virtual Memory: In Use" /C:"Domain" /C:"Network Card(s)">temp.txt
if exist systeminfo.html del /f /q systeminfo.html
call :CreateHTMLtable temp.txt systeminfo.html
if exist temp.txt del /f /q temp.txt
exit /b

:CreateHTMLTable <inputfile> <outputfile>
setlocal
>%2 echo ^<!DOCTYPE HTML PUBLIC 
>>%2 echo "-//W3C//DTD HTML 4.01 Transitional//EN"
>>%2 echo  "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"^>
>>%2 echo ^<HTML^>
>>%2 echo ^<HEAD^>
>>%2 echo ^<META HTTP-EQUIV="Content-Type" 
>>%2 echo CONTENT="text/html; charset=utf-8"^>
>>%2 echo ^</HEAD^>
>>%2 echo ^<BODY^>
>>%2 echo ^<style type="text/css"^>
>>%2 echo .tftable {font-size:12px;color:#333333;width:100%;border-width: 1px;border-color: #bcaf91;border-collapse: collapse;}
>>%2 echo .tftable th {font-size:12px;background-color:#ded0b0;border-width: 1px;padding: 8px;border-style: solid;border-color: #bcaf91;text-align:left;}
>>%2 echo .tftable tr {background-color:#e9dbbb;}
>>%2 echo .tftable td {font-size:12px;border-width: 1px;padding: 8px;border-style: solid;border-color: #bcaf91;}
>>%2 echo .tftable tr:hover {background-color:#ffffff;}
>>%2 echo ^</style^>
>>%2 echo ^<table class="tftable" border="1"^>
for /f "tokens=1,2 delims=:" %%a in (%1) do (
>>%2 echo ^<tr^>^<td^>%%a^</td^>^<td^>%%b^</td^>^</tr^>
)
>>%2 echo ^</table^>
>>%2 echo ^</BODY^>
>>%2 echo ^</HTML^>
@echo关闭
systeminfo | findstr/B/C:“操作系统名称”/C:“操作系统版本”/C:“操作系统制造商”/C:“操作系统构建类型”/C:“原始安装日期”/C:“系统启动时间”/C:“系统制造商”/C:“系统型号”/C:“处理器”/C:“BIOS版本”/C:“Windows目录”/C:“系统目录”/C:“启动设备”/C:“系统区域设置”/C:输入区域设置“/C:“总物理内存”/C:“可用物理内存”/C:“虚拟内存:最大大小”/C:“虚拟内存:可用”/C:“虚拟内存:正在使用”/C:“域”/C:“网卡”>temp.txt
如果存在systeminfo.html del/f/q systeminfo.html
调用:CreateHTMLtable temp.txt systeminfo.html
如果存在temp.txt del/f/q temp.txt
退出/b
:CreateHTMLTable
setlocal
>%2 echo^>%2 echo“-//W3C//DTD HTML 4.01过渡版//EN”
>>%2回声“http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"^>
>>%2回声^
>>%2回声^
>>%2 echo^>%2 echo CONTENT=“text/html;字符集=utf-8“^>
>>%2回声^
>>%2回声^
>>%2回声^
>>%2 echo.tftable{字体大小:12px;颜色:#333333;宽度:100%;边框宽度:1px;边框颜色:#bcaf91;边框折叠:折叠;}
>>%2 echo.tftable th{font size:12px;背景色:#ded0b0;边框宽度:1px;填充:8px;边框样式:纯色;边框颜色:#bcaf91;文本对齐:左;}
>>%2 echo.tftable tr{背景色:#e9dbbb;}
>>%2 echo.tftable td{字体大小:12px;边框宽度:1px;填充:8px;边框样式:纯色;边框颜色:#bcaf91;}
>>%2 echo.tftable tr:hover{背景色:#ffffff;}
>>%2回声^
>>%2回声^
对于/f“令牌=1,2 delims=:”%a在(%1)do中(
>>%2回声^^%%a^^%%b^^
)
>>%2回声^
>>%2回声^
>>%2回声^

+1:但您不需要多次重定向,将所有内容都括在括号中,只重定向一次:
(echo^@jeb-haha,谢谢,那会更方便。我将更新我的答案。我如何才能将表格居中,并更改左栏中的名称(操作系统版本等)?谢谢!可能是重复的