Windows Batch System Info to HTML

后端 未结 2 2041
耶瑟儿~
耶瑟儿~ 2020-12-11 08:38

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

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-11 09:11

    It all depends on how fancy you want to get. The simplest way would be

    @echo off
    (
    echo ^ 
    echo ^ 
    echo ^ 
    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 ^ 
    echo ^ 
    echo ^
    )>sysinfo.html
    

    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  
    setlocal
    >%2 echo ^>%2 echo "-//W3C//DTD HTML 4.01 Transitional//EN"
    >>%2 echo  "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"^>
    >>%2 echo ^
    >>%2 echo ^
    >>%2 echo ^>%2 echo CONTENT="text/html; charset=utf-8"^>
    >>%2 echo ^
    >>%2 echo ^
    >>%2 echo ^