本文介紹了Windows 批處理系統(tǒng)信息到 HTML的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時送ChatGPT賬號..
我正在嘗試創(chuàng)建一個批處理文件,該文件將使用 systeminfo 命令將諸如操作系統(tǒng)、當(dāng)前登錄的域、制造商、計算機(jī)型號等內(nèi)容放入 HTML 表中.這是我當(dāng)前批處理文件的內(nèi)容:
I am trying to create a batch file that will use the systeminfo command to put things such as the OS, domain currently logged onto, manufacture, computer model, etc. into an HTML table. This is the contents of my current batch file:
@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
這是當(dāng)前的輸出:
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 表格中?任何幫助將不勝感激!謝謝.
How can I put this into a HTML table? Any help would be greatly appreciated! Thanks.
推薦答案
這一切都取決于你想獲得多花哨.最簡單的方法是
It all depends on how fancy you want to get. The simplest way would be
@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
這是一種使用 CSS 格式化表格的方法
And here is a way with a CSS formatted table
@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^>
這篇關(guān)于Windows 批處理系統(tǒng)信息到 HTML的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!