[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[系统相关] 【wmic硬件检测-gfd5.3】新手发帖:简单获取电脑信息并保存,慢慢完善更新

本帖最后由 gfd 于 2024-1-17 11:54 编辑

我一直在用的代码,不定时更新。
主要用途:获取电脑的序列号、配置信息,然后保存到文件中。我是卖电脑的,收集这些信息可以记录电脑序列,销售日期,方便后期的保修查询等。
代码都是东拼西凑弄来的,大神有更好的建议欢迎提出,谢谢。
  1. @echo off&color e&title gfd硬件检测_5.2
  2. mode con cols=110 lines=70
  3. setlocal enabledelayedexpansion
  4. echo 信息提取时间:%date%      时间 %Time%
  5. for /f "tokens=1* delims=:=" %%a in ('"wmic os get Caption,InstallDate,OSArchitecture,Version /Format:List"') do (
  6.     IF /I "%%a"=="Caption" set Caption=%%b
  7.     IF /I "%%a"=="InstallDate" set InstallDate=%%b
  8.     IF /I "%%a"=="OSArchitecture" set OSArchitecture=%%b
  9.     IF /I "%%a"=="Version" set Version=%%b
  10. )
  11. echo Windows_信息:%Caption%%Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
  12. echo.
  13. echo 主版:
  14. for /f "tokens=1* delims==" %%a in ('"wmic csproduct get IdentifyingNumber,Name,Vendor,Version /value|more +2"') do (
  15.     IF /I "%%a"=="IdentifyingNumber" set IdentifyingNumber=%%b
  16.     IF /I "%%a"=="Name" set Name=%%b
  17.     IF /I "%%a"=="Vendor" set Vendor=%%b
  18.     IF /I "%%a"=="Version" set VersionZ=%%b
  19. )
  20. echo     供应商:%Vendor%
  21. echo     系  列:%Name%
  22. echo     型  号:%VersionZ%
  23. echo     序列号:%IdentifyingNumber%&echo.&echo.
  24. REM 处理器
  25. for /f "tokens=2 delims==" %%a in ('"wmic cpu Get DeviceID /value"') do set /a CPUQuantity+=1
  26. echo CPU :【%CPUQuantity% 颗】
  27. for /f "tokens=1* delims==" %%a in ('"wmic cpu get MaxClockSpeed,Name,NumberOfCores,NumberOfLogicalProcessors /value"') do (
  28.     IF /I "%%a"=="MaxClockSpeed" set MaxClockSpeed=%%b
  29.     IF /I "%%a"=="Name" set NameC=%%b
  30.     IF /I "%%a"=="NumberOfCores" set NumberOfCores=%%b
  31.     IF /I "%%a"=="NumberOfLogicalProcessors" set NumberOfLogicalProcessors=%%b
  32. )
  33. echo     名  称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】
  34. echo     主  频:%MaxClockSpeed%&echo.&echo.
  35. REM 内存
  36. for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Tag /value"') do set /a MemoryQuantity+=1
  37. echo 内存:【%MemoryQuantity% 条】
  38. for /f "tokens=2 delims==" %%a in ('"wmic memorychip get Capacity /value"') do (
  39.     set "Capacity=%%a"
  40.     for /f "tokens=1 delims=." %%b in ("!Capacity:~,-7!/1073") do set /a m+=%%b
  41.     )
  42. call echo     总容量:%%m%% GB
  43. for /f "tokens=1* delims==" %%a in ('"wmic memorychip get ConfiguredClockSpeed /value"') do (
  44.     IF /I "%%a" == "ConfiguredClockSpeed" set ConfiguredClockSpeed=%%b
  45. )
  46. echo     频  率:%ConfiguredClockSpeed%&echo.&echo.
  47. REM 硬盘
  48. for /f "tokens=2 delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' get Caption /value"') do set /a DiskQuantity+=1
  49. echo 硬盘:【%DiskQuantity% 块】
  50. set "Model=   型  号:"&set "SerialNumber=   序列号:"&set "size=   容  量:"
  51. for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' get Model,SerialNumber,Size /value|more +2"') do echo. !%%a!%%b
  52. echo 显示:
  53. for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController get CurrentRefreshRate,DeviceID,MaxRefreshRate,MinRefreshRate,Name,VideoModeDescription /value"') do (
  54.     IF /I "%%a"=="CurrentRefreshRate" (
  55.         echo.    当前刷新率: %%b)
  56.     IF /I "%%a"=="DeviceID" (
  57.         echo.    设  备  ID: %%b)
  58.     IF /I "%%a"=="MaxRefreshRate" (
  59.         echo.    最高刷新率: %%b)
  60.     IF /I "%%a"=="MinRefreshRate" (
  61.         echo.    最低刷新率: %%b)
  62.     IF /I "%%a"=="Name" (
  63.         echo.    显卡  名称: %%b)
  64.     IF /I "%%a"=="VideoModeDescription" (
  65.         echo.    当前分辨率: %%b
  66.         echo ----------------------------)
  67. )
  68. echo.&echo.
  69. echo BIOS:
  70. for /f "tokens=1* delims=:=" %%a in ('"wmic bios get BIOSVersion,Manufacturer,Name,ReleaseDate,SerialNumber,SMBIOSBIOSVersion,Version /Format:List"') do (
  71.     IF /I "%%a"=="ReleaseDate" set ReleaseDate=%%b
  72.     IF /I "%%a"=="SerialNumber" set SerialNumberB=%%b
  73.     IF /I "%%a"=="Manufacturer" set Manufacturer=%%b
  74.     IF /I "%%a"=="Name" set NameB=%%b
  75.     IF /I "%%a"=="Version" set VersionB=%%b
  76.     IF /I "%%a"=="BIOSVersion" set BIOSVersion=%%b
  77.     IF /I "%%a"=="SMBIOSBIOSVersion" set SMBIOSBIOSVersion=%%b
  78. )
  79. echo     制  造  商:%Manufacturer%
  80. echo     名      称:%NameB%
  81. echo     版      本:%VersionB%
  82. echo     BIOS  版本:%BIOSVersion%
  83. echo     SMBIOS版本:%SMBIOSBIOSVersion%
  84. echo     固件  日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
  85. echo     序  列  号:%SerialNumberB%
  86. echo.
  87. echo 信息提取完成,按任意键保存到文本中。
  88. pause>nul
  89. REM ==========保存信息到文件中,如果不需要,删除下面所有==========
  90. echo 信息提取时间:%date%      时间 %Time%>>wmic硬件信息gfd.txt
  91. echo Windows_信息:%Caption%%Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒>>wmic硬件信息gfd.txt
  92. echo.>>wmic硬件信息gfd.txt
  93. echo 主版:>>wmic硬件信息gfd.txt
  94. echo     供应商:%Vendor%>>wmic硬件信息gfd.txt
  95. echo     系  列:%Name%>>wmic硬件信息gfd.txt
  96. echo     型  号:%VersionZ%>>wmic硬件信息gfd.txt
  97. echo     序列号:%IdentifyingNumber%>>wmic硬件信息gfd.txt
  98. echo. >>wmic硬件信息gfd.txt
  99. echo. >>wmic硬件信息gfd.txt
  100. REM 处理器
  101. echo CPU :【%CPUQuantity% 颗】>>wmic硬件信息gfd.txt
  102. echo     名  称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】>>wmic硬件信息gfd.txt
  103. echo     主  频:%MaxClockSpeed%>>wmic硬件信息gfd.txt
  104. echo. >>wmic硬件信息gfd.txt
  105. echo. >>wmic硬件信息gfd.txt
  106. REM 内存
  107. echo 内存:【%MemoryQuantity% 条】>>wmic硬件信息gfd.txt
  108. echo     总容量:%m% GB>>wmic硬件信息gfd.txt
  109. echo     频  率:%ConfiguredClockSpeed%>>wmic硬件信息gfd.txt
  110. echo. >>wmic硬件信息gfd.txt
  111. echo. >>wmic硬件信息gfd.txt
  112. REM 硬盘
  113. echo 硬盘:【%DiskQuantity% 块】>>wmic硬件信息gfd.txt
  114. set "Model=   型  号:"&set "SerialNumber=   序列号:"&set "size=   容  量:"
  115. for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' get Model,SerialNumber,Size /value|more +2"') do echo. !%%a!%%b>>wmic硬件信息gfd.txt
  116. echo 显示:>>wmic硬件信息gfd.txt
  117. for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController get CurrentRefreshRate,DeviceID,MaxRefreshRate,MinRefreshRate,Name,VideoModeDescription /value"') do (
  118.     IF /I "%%a"=="CurrentRefreshRate" (
  119.         echo.    当前刷新率: %%b>>wmic硬件信息gfd.txt)
  120.     IF /I "%%a"=="DeviceID" (
  121.         echo.    设  备  ID: %%b>>wmic硬件信息gfd.txt)
  122.     IF /I "%%a"=="MaxRefreshRate" (
  123.         echo.    最高刷新率: %%b>>wmic硬件信息gfd.txt)
  124.     IF /I "%%a"=="MinRefreshRate" (
  125.         echo.    最低刷新率: %%b>>wmic硬件信息gfd.txt)
  126.     IF /I "%%a"=="Name" (
  127.         echo.    显卡  名称: %%b>>wmic硬件信息gfd.txt)
  128.     IF /I "%%a"=="VideoModeDescription" (
  129.         echo.    当前分辨率: %%b>>wmic硬件信息gfd.txt
  130.         echo ---------------------------->>wmic硬件信息gfd.txt)
  131. )
  132. echo. >>wmic硬件信息gfd.txt
  133. echo. >>wmic硬件信息gfd.txt
  134. echo BIOS:>>wmic硬件信息gfd.txt
  135. echo     制  造  商:%Manufacturer%>>wmic硬件信息gfd.txt
  136. echo     名      称:%NameB%>>wmic硬件信息gfd.txt
  137. echo     版      本:%VersionB%>>wmic硬件信息gfd.txt
  138. echo     BIOS  版本:%BIOSVersion%>>wmic硬件信息gfd.txt
  139. echo     SMBIOS版本:%SMBIOSBIOSVersion%>>wmic硬件信息gfd.txt
  140. echo     固件  日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日>>wmic硬件信息gfd.txt
  141. echo     序  列  号:%SerialNumberB%>>wmic硬件信息gfd.txt
  142. echo   ****************************************页尾****************************************>>wmic硬件信息gfd.txt
复制代码
1

评分人数

    • 77七: 感谢分享技术 + 1

本帖最后由 gfd 于 2024-1-17 12:00 编辑

5.3更新
显示每条内存信息
显示每块硬盘信息(10进制截取GB容量)
代码如下:
  1. @echo off&setlocal enabledelayedexpansion&title gfd硬件检测_5.3
  2. REM 日期时间
  3. for /f "tokens=1* delims=:=" %%a in ('"wmic os Get Caption,InstallDate,OSArchitecture,Version /value"') do (
  4.     IF /I "%%a"=="Caption" set Caption=%%b
  5.     IF /I "%%a"=="InstallDate" set InstallDate=%%b
  6.     IF /I "%%a"=="OSArchitecture" set OSArchitecture=%%b
  7.     IF /I "%%a"=="Version" set Version=%%b
  8. )
  9. echo 信息提取时间:%date%      时间 %Time%
  10. echo Windows_信息:%Caption%%Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
  11. echo.
  12. REM 产品 csproduct
  13. for /f "tokens=1* delims==" %%a in ('"wmic csproduct Get IdentifyingNumber,Name,Vendor,Version /value"') do (
  14.     IF /I "%%a"=="IdentifyingNumber" set IdenCS=%%b
  15.     IF /I "%%a"=="Name" set NameCS=%%b
  16.     IF /I "%%a"=="Vendor" set VendCS=%%b
  17.     IF /I "%%a"=="Version" set VersCS=%%b
  18. )
  19. REM 主板 baseboard
  20. for /f "tokens=1* delims=:=" %%i in ('"wmic baseboard get Manufacturer,Product,SerialNumber /value"') do (
  21.     IF /I "%%i"=="Manufacturer" set ManuZB=%%j
  22.     IF /I "%%i"=="Product" set ProdZB=%%j
  23.     IF /I "%%i"=="SerialNumber" set SeriZB=%%j
  24. )
  25. REM 系统管理 ComputerSystem
  26. for /f "tokens=1* delims=:=" %%i in ('"wmic ComputerSystem get Manufacturer,SystemFamily,SystemSKUNumber /value"') do (
  27.     IF /I "%%i"=="Manufacturer" set ManuSY=%%j
  28.     IF /I "%%i"=="SystemFamily" set FamiSY=%%j
  29.     IF /I "%%i"=="SystemSKUNumber" set SKUNSY=%%j
  30. )
  31. echo 产品:
  32. echo     供应商:%VendCS%
  33. echo     系  列:%NameCS%
  34. echo     型  号:%VersCS%
  35. echo     序列号:%IdenCS%
  36. echo 主板:
  37. echo     制造商:%ManuZB%
  38. echo     产  品:%ProdZB%
  39. echo     序列号:%SeriZB%
  40. echo System:
  41. echo     制造商:%ManuSY%
  42. echo     产品线:%FamiSY%
  43. echo     序列号:%SKUNSY%&echo.&echo.
  44. REM 处理器
  45. for /f "tokens=2 delims==" %%a in ('"wmic cpu Get DeviceID /value"') do set /a CPUQuantity+=1
  46. for /f "tokens=1* delims==" %%a in ('"wmic cpu Get MaxClockSpeed,Name,NumberOfCores,NumberOfLogicalProcessors /value"') do (
  47.     IF /I "%%a"=="MaxClockSpeed" set MaxClockSpeed=%%b
  48.     IF /I "%%a"=="Name" set NameC=%%b
  49.     IF /I "%%a"=="NumberOfCores" set NumberOfCores=%%b
  50.     IF /I "%%a"=="NumberOfLogicalProcessors" set NumberOfLogicalProcessors=%%b
  51. )
  52. echo CPU :【%CPUQuantity% 颗】
  53. echo     名  称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】
  54. echo     主  频:%MaxClockSpeed%&echo.&echo.
  55. REM 内存
  56. for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Tag /value"') do set /a MemoryQuantity+=1
  57. for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Capacity /value"') do (
  58.     set Capacity=%%a
  59.     set /a NCG=!Capacity:~,-7!/1073
  60.     set /a m+=!NCG!
  61. )
  62. for /f "tokens=1* delims==" %%a in ('"wmic memorychip where Tag='Physical Memory 0' Get ConfiguredClockSpeed /value"') do (
  63.     IF /I "%%a"=="ConfiguredClockSpeed" set ConfiguredClockSpeed=%%b
  64. )
  65. echo 内存:【%MemoryQuantity% 条】
  66. echo     总容量:!m! GB  【当前频率:%ConfiguredClockSpeed% MHz】
  67. echo     ----------------------------
  68. for /f "tokens=1* delims==" %%a in ('"wmic memorychip Get Capacity,Manufacturer,SerialNumber,Speed /value"') do (
  69.     IF /I "%%a"=="Capacity" (
  70.         set Capacity=%%b
  71.         set /a NCG=!Capacity:~,-7!/1073
  72.         set /a NC+=1
  73.         echo.          内存!NC! :%NCG% GB)
  74.     IF /I "%%a"=="Manufacturer" (
  75.         echo.        品    牌:%%b)
  76.     IF /I "%%a"=="SerialNumber" (
  77.         echo.        序 列 号:%%b)
  78.     IF /I "%%a"=="Speed" (
  79.         echo.        最高频率:%%b
  80.         echo     ----------------------------)
  81. )
  82. echo.&echo.
  83. REM 硬盘
  84. for /f "tokens=2 delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Caption /value"') do set /a DiskQuantity+=1
  85. echo 硬盘:【%DiskQuantity% 块】
  86. for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Model,SerialNumber,Size /value"') do (
  87.     IF /I "%%a"=="Model" (
  88.         set /a YP+=1
  89.         echo.    硬盘 !YP!:%%b)
  90.     IF /I "%%a"=="SerialNumber" (
  91.         echo.    序列号:%%b)
  92.     IF /I "%%a"=="Size" (
  93.         set Size=%%b
  94.         echo.    容  量:!Size:~,-10! GB
  95.         echo     ----------------------------)
  96. )
  97. echo.&echo.
  98. echo 显示:
  99. for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController Get CurrentRefreshRate,MaxRefreshRate,Name,VideoModeDescription /value"') do (
  100.     IF /I "%%a"=="CurrentRefreshRate" (
  101.         echo.    当前刷新率: %%b)
  102.     IF /I "%%a"=="MaxRefreshRate" (
  103.         echo.    最高刷新率: %%b)
  104.     IF /I "%%a"=="Name" (
  105.         echo.    显卡  名称: %%b)
  106.     IF /I "%%a"=="VideoModeDescription" (
  107.         echo.    当前分辨率: %%b
  108.         echo     ----------------------------)
  109. )
  110. echo.&echo.
  111. REM BIOS
  112. for /f "tokens=1* delims=:=" %%a in ('"wmic bios Get BIOSVersion,Manufacturer,Name,ReleaseDate,SerialNumber,SMBIOSBIOSVersion,Version /value"') do (
  113.     IF /I "%%a"=="ReleaseDate" set ReleaseDate=%%b
  114.     IF /I "%%a"=="SerialNumber" set SeriBI=%%b
  115.     IF /I "%%a"=="Manufacturer" set ManuBI=%%b
  116.     IF /I "%%a"=="Name" set NameBI=%%b
  117.     IF /I "%%a"=="Version" set VersBI=%%b
  118.     IF /I "%%a"=="BIOSVersion" set BIOSVersion=%%b
  119.     IF /I "%%a"=="SMBIOSBIOSVersion" set SMBIOSBIOSVersion=%%b
  120. )
  121. echo BIOS:
  122. echo     制  造  商:%ManuBI%
  123. echo     名      称:%NameBI%
  124. echo     版      本:%VersBI%
  125. echo     BIOS  版本:%BIOSVersion%
  126. echo     SMBIOS版本:%SMBIOSBIOSVersion%
  127. echo     固件  日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
  128. echo     序  列  号:%SeriBI%
  129. echo.
  130. echo 信息提取完成,按任意键保存到文本中。
  131. pause>nul
  132. REM ==========保存信息到文件中,如果不需要,删除下面所有==========
  133. (echo 信息提取时间:%date%      时间 %Time%
  134. echo Windows_信息:%Caption%%Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
  135. echo.
  136. echo 产品:
  137. echo     供应商:%VendCS%
  138. echo     系  列:%NameCS%
  139. echo     型  号:%VersCS%
  140. echo     序列号:%IdenCS%
  141. echo 主板:
  142. echo     制造商:%ManuZB%
  143. echo     产  品:%ProdZB%
  144. echo     序列号:%SeriZB%
  145. echo System:
  146. echo     制造商:%ManuSY%
  147. echo     产品线:%FamiSY%
  148. echo     序列号:%SKUNSY%
  149. echo.)>>硬件信息gfd5.txt
  150. echo CPU :【%CPUQuantity% 颗】>>硬件信息gfd5.txt
  151. echo     名  称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】>>硬件信息gfd5.txt
  152. echo     主  频:%MaxClockSpeed%>>硬件信息gfd5.txt
  153. echo.>>硬件信息gfd5.txt
  154. echo 内存:【%MemoryQuantity% 条】>>硬件信息gfd5.txt
  155. echo     总容量:%m% GB  【当前频率:%ConfiguredClockSpeed% MHz】>>硬件信息gfd5.txt
  156. echo     ---------------------------->>硬件信息gfd5.txt
  157. for /f "tokens=1* delims==" %%a in ('"wmic memorychip Get Capacity,Manufacturer,SerialNumber,Speed /value"') do (
  158.     IF /I "%%a"=="Capacity" (
  159.         set CapaTXT=%%b
  160.         set /a NCG=!CapaTXT:~,-7!/1073
  161.         set /a NCTXT+=1
  162.         echo.          内存!NCTXT! :%NCG% GB>>硬件信息gfd5.txt)
  163.     IF /I "%%a"=="Manufacturer" (
  164.         echo.        品    牌:%%b>>硬件信息gfd5.txt)
  165.     IF /I "%%a"=="SerialNumber" (
  166.         echo.        序 列 号:%%b>>硬件信息gfd5.txt)
  167.     IF /I "%%a"=="Speed" (
  168.         echo.        最高频率:%%b>>硬件信息gfd5.txt
  169.         echo     ---------------------------->>硬件信息gfd5.txt))
  170. (echo.
  171. echo 硬盘:【%DiskQuantity% 块】)>>硬件信息gfd5.txt
  172. for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Model,SerialNumber,Size /value"') do (
  173.     IF /I "%%a"=="Model" (
  174.         set /a YPTXT+=1
  175.         echo.    硬盘 !YPTXT!:%%b>>硬件信息gfd5.txt)
  176.     IF /I "%%a"=="SerialNumber" (
  177.         echo.    序列号:%%b>>硬件信息gfd5.txt)
  178.     IF /I "%%a"=="Size" (
  179.         set Size=%%b
  180.         echo.    容  量:!Size:~,-10! GB>>硬件信息gfd5.txt
  181.         echo     ---------------------------->>硬件信息gfd5.txt))
  182. (echo.
  183. echo 显示:)>>硬件信息gfd5.txt
  184. for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController Get CurrentRefreshRate,MaxRefreshRate,Name,VideoModeDescription /value"') do (
  185.     IF /I "%%a"=="CurrentRefreshRate" (
  186.         echo.    当前刷新率: %%b>>硬件信息gfd5.txt)
  187.     IF /I "%%a"=="MaxRefreshRate" (
  188.         echo.    最高刷新率: %%b>>硬件信息gfd5.txt)
  189.     IF /I "%%a"=="Name" (
  190.         echo.    显卡  名称: %%b>>硬件信息gfd5.txt)
  191.     IF /I "%%a"=="VideoModeDescription" (
  192.         echo.    当前分辨率: %%b>>硬件信息gfd5.txt
  193.         echo     ---------------------------->>硬件信息gfd5.txt))
  194. (echo.
  195. echo BIOS:
  196. echo     制  造  商:%ManuBI%
  197. echo     名      称:%NameBI%
  198. echo     版      本:%VersBI%
  199. echo     BIOS  版本:%BIOSVersion%
  200. echo     SMBIOS版本:%SMBIOSBIOSVersion%
  201. echo     固件  日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
  202. echo     序  列  号:%SeriBI%
  203. echo   ****************************************页尾****************************************
  204. )>>硬件信息gfd5.txt
  205. echo.&echo 已保存,稍后自动退出。&echo.
  206. timeout /T 3 >nul
复制代码

TOP

回复 1# gfd


建议改成 powershell

TOP

回复 3# newswan


    不太会,我是个半吊子,大部分都是抄袭拼凑的。您要是方便给改改,谢谢

TOP

如果有显示器+打印机等设备信息,就适合单位资产清点了。

TOP

回复 4# gfd


    晚点试试ai

TOP

回复 5# ppll2030


有资产管理软件,aida64 也许可以

TOP

回复 5# ppll2030


    http://www.bathome.net/thread-38259-1-1.html
这个有打印机  显示器。dx获取到的  时间久点

TOP

  1. PowerShell脚本相对于批处理脚本具有许多优势和劣势。
  2. 优势:
  3. 强大的对象模型:PowerShell是基于对象的脚本语言,可以轻松地处理和操作对象,而不仅仅是文本流。
  4. 内置的.NET集成:PowerShell可以直接访问.NET Framework,因此可以利用.NET库中的丰富功能。
  5. 更丰富的功能:PowerShell具有更多的内置功能和命令,可以更轻松地执行系统管理任务。
  6. 更好的错误处理:PowerShell提供了更强大的错误处理和调试功能,使得编写和调试脚本更加容易。
  7. 更好的安全性:PowerShell具有更多的安全功能和策略,可以更好地控制脚本的执行和访问权限。
  8. 劣势:
  9. 学习曲线:对于习惯了批处理脚本的用户来说,学习PowerShell可能需要一些时间。
  10. 兼容性:某些较旧的Windows系统可能不支持PowerShell,因此在这些系统上可能无法运行PowerShell脚本。
  11. 执行速度:相对于简单的批处理脚本,PowerShell脚本可能会有更长的启动时间和执行时间。
  12. 总的来说,PowerShell脚本在系统管理和自动化方面具有更多的优势,但对于简单的任务和较旧的系统,批处理脚本可能仍然是一个更简单和直接的选择。
复制代码

TOP

  1. # 获取操作系统信息
  2. $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object Caption, InstallDate, OSArchitecture, Version
  3. $osInfo.InstallDate = $osInfo.InstallDate.ToString("yyyyMMddHHmmss")
  4. Write-Host "信息提取时间:" (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
  5. Write-Host "Windows_信息:" ($osInfo.Caption + $osInfo.Version) + " 【" + $osInfo.OSArchitecture + "】 安装日期:" + $osInfo.InstallDate.Substring(0, 4) + "年" + $osInfo.InstallDate.Substring(4, 2) + "月" + $osInfo.InstallDate.Substring(6, 2) + "日_" + $osInfo.InstallDate.Substring(8, 2) + "点" + $osInfo.InstallDate.Substring(10, 2) + "分" + $osInfo.InstallDate.Substring(12, 2) + "秒"
  6. Write-Host ""
  7. # 获取产品信息
  8. $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct | Select-Object IdentifyingNumber, Name, Vendor, Version
  9. Write-Host "产品:"
  10. Write-Host "    供应商:" $productInfo.Vendor
  11. Write-Host "    系  列:" $productInfo.Name
  12. Write-Host "    型  号:" $productInfo.Version
  13. Write-Host "    序列号:" $productInfo.IdentifyingNumber
  14. Write-Host ""
  15. # 获取主板信息
  16. $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard | Select-Object Manufacturer, Product, SerialNumber
  17. Write-Host "主板:"
  18. Write-Host "    制造商:" $baseboardInfo.Manufacturer
  19. Write-Host "    产  品:" $baseboardInfo.Product
  20. Write-Host "    序列号:" $baseboardInfo.SerialNumber
  21. Write-Host ""
  22. # 获取处理器信息
  23. $processorInfo = Get-CimInstance -ClassName Win32_Processor | Select-Object Name, MaxClockSpeed, NumberOfCores, NumberOfLogicalProcessors
  24. Write-Host "CPU :【" + ($processorInfo.Count) + " 颗】"
  25. foreach ($processor in $processorInfo) {
  26.     Write-Host "    名  称:" $processor.Name + "【" + $processor.NumberOfCores + "核" + $processor.NumberOfLogicalProcessors + "线程】"
  27.     Write-Host "    主  频:" $processor.MaxClockSpeed
  28. }
  29. Write-Host ""
  30. # 获取内存信息
  31. $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
  32. Write-Host "内存:【" + ($memoryInfo.Count) + " 条】"
  33. $totalMemory = ($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB
  34. Write-Host "    总容量:" $totalMemory "GB"
  35. foreach ($memory in $memoryInfo) {
  36.     Write-Host "    内存:" ($memory.Capacity / 1GB) "GB"
  37.     Write-Host "        品    牌:" $memory.Manufacturer
  38.     Write-Host "        序 列 号:" $memory.SerialNumber
  39.     Write-Host "        最高频率:" $memory.Speed
  40. }
  41. Write-Host ""
  42. # 获取硬盘信息
  43. $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
  44. Write-Host "硬盘:【" + ($diskInfo.Count) + " 块】"
  45. foreach ($disk in $diskInfo) {
  46.     Write-Host "    硬盘:" $disk.Model
  47.     Write-Host "    序列号:" $disk.SerialNumber
  48.     Write-Host "    容  量:" ($disk.Size / 1GB) "GB"
  49. }
  50. Write-Host ""
  51. # 获取显示信息
  52. $videoInfo = Get-CimInstance -ClassName Win32_VideoController | Select-Object CurrentRefreshRate, MaxRefreshRate, Name, VideoModeDescription
  53. Write-Host "显示:"
  54. foreach ($video in $videoInfo) {
  55.     Write-Host "    当前刷新率:" $video.CurrentRefreshRate
  56.     Write-Host "    最高刷新率:" $video.MaxRefreshRate
  57.     Write-Host "    显卡  名称:" $video.Name
  58.     Write-Host "    当前分辨率:" $video.VideoModeDescription
  59. }
  60. Write-Host ""
  61. # 获取BIOS信息
  62. $biosInfo = Get-CimInstance -ClassName Win32_BIOS | Select-Object BIOSVersion, Manufacturer, Name, ReleaseDate, SerialNumber, SMBIOSBIOSVersion, Version
  63. $biosInfo.ReleaseDate = $biosInfo.ReleaseDate.ToString("yyyyMMdd")
  64. Write-Host "BIOS:"
  65. Write-Host "    制  造  商:" $biosInfo.Manufacturer
  66. Write-Host "    名      称:" $biosInfo.Name
  67. Write-Host "    版      本:" $biosInfo.Version
  68. Write-Host "    BIOS  版本:" $biosInfo.BIOSVersion
  69. Write-Host "    SMBIOS版本:" $biosInfo.SMBIOSBIOSVersion
  70. Write-Host "    固件  日期:" $biosInfo.ReleaseDate.Substring(0, 4) + "年" + $biosInfo.ReleaseDate.Substring(4, 2) + "月" + $biosInfo.ReleaseDate.Substring(6, 2) + "日"
  71. Write-Host "    序  列  号:" $biosInfo.SerialNumber
复制代码

TOP

上面的是 ai 改写的

TOP

整理过的
  1. Write-Host "信息提取时间:" (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
  2. Write-Host ""
  3. # 获取操作系统信息
  4. $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
  5. Write-Host "系统版本:$($osInfo.Caption) $($osInfo.Version) 【 $($osInfo.OSArchitecture) 】"
  6. Write-Host "安装日期:$( $osInfo.InstallDate.ToString('yyyy-MM-dd') )"
  7. Write-Host ""
  8. # 获取产品信息
  9. $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct
  10. Write-Host "产品:"
  11. Write-Host "    供应商:" $productInfo.Vendor
  12. Write-Host "    系  列:" $productInfo.Name
  13. Write-Host "    型  号:" $productInfo.Version
  14. Write-Host "    序列号:" $productInfo.IdentifyingNumber
  15. Write-Host ""
  16. # 获取主板信息
  17. $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard
  18. Write-Host "主板:"
  19. Write-Host "    制造商:" $baseboardInfo.Manufacturer
  20. Write-Host "    产  品:" $baseboardInfo.Product
  21. Write-Host "    序列号:" $baseboardInfo.SerialNumber
  22. Write-Host ""
  23. # 获取处理器信息
  24. $processorInfo = Get-CimInstance -ClassName Win32_Processor
  25. Write-Host "CPU :【 $( ($processorInfo | Measure-Object).Count ) 颗 】"
  26. foreach ($processor in $processorInfo) {
  27.     Write-Host "    名  称: $($processor.Name) 【 $($processor.NumberOfCores) 核 $($processor.NumberOfLogicalProcessors) 线程 】"
  28.     Write-Host "    主  频:" $processor.MaxClockSpeed
  29. }
  30. Write-Host ""
  31. # 获取内存信息
  32. $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
  33. Write-Host "内存:【 $( ($memoryInfo | Measure-Object).Count ) 条 】"
  34. Write-Host "    总容量: $(($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB) GB"
  35. foreach ($memory in $memoryInfo) {
  36.     Write-Host "    内存: $($memory.Capacity / 1GB) GB"
  37.     Write-Host "        品    牌: $($memory.Manufacturer)"
  38.     Write-Host "        序 列 号: $($memory.SerialNumber)"
  39.     Write-Host "        最高频率: $($memory.Speed)"
  40. }
  41. Write-Host ""
  42. # 获取硬盘信息
  43. $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
  44. Write-Host "硬盘:【 $( ($diskInfo | Measure-Object).Count ) 块 】"
  45. foreach ($disk in $diskInfo) {
  46.     Write-Host "    硬盘: $($disk.Model)"
  47.     Write-Host "    序列号: $($disk.SerialNumber)"
  48.     Write-Host "    容  量: $($disk.Size / 1GB) GB"
  49. }
  50. Write-Host ""
  51. # 获取显示信息
  52. $videoInfo = Get-CimInstance -ClassName Win32_VideoController
  53. Write-Host "显示:"
  54. foreach ($video in $videoInfo) {
  55.     Write-Host "    当前刷新率: "$video.CurrentRefreshRate
  56.     Write-Host "    最高刷新率: "$video.MaxRefreshRate
  57.     Write-Host "    显卡  名称: "$video.Name
  58.     Write-Host "    当前分辨率: "$video.VideoModeDescription
  59. }
  60. Write-Host ""
  61. # 获取BIOS信息
  62. $biosInfo = Get-CimInstance -ClassName Win32_BIOS
  63. Write-Host "BIOS:"
  64. Write-Host "    制  造  商: "$biosInfo.Manufacturer
  65. Write-Host "    名      称: "$biosInfo.Name
  66. Write-Host "    版      本: "$biosInfo.Version
  67. Write-Host "    BIOS  版本: "$biosInfo.BIOSVersion
  68. Write-Host "    SMBIOS版本: "$biosInfo.SMBIOSBIOSVersion
  69. Write-Host "    固件  日期: "$biosInfo.ReleaseDate.ToString('yyyy-MM-dd')
  70. Write-Host "    序  列  号: "$biosInfo.SerialNumber
  71. Write-Host ""
  72. pause
复制代码

TOP

回复 12# newswan


    谢谢,我试试。

TOP

本帖最后由 gfd 于 2024-1-17 20:26 编辑

回复 12# newswan


    很好。
获取时间比批处理慢一些。
内存和硬盘不显示序列号(硬盘1、硬盘2……)再加上判定硬盘机械?固态?
能不能获取显卡显存容量(cmd显存最大4G),还有显示器品牌型号的信息
怎么保存到文件中?

TOP

加 nvme 识别
  1. Write-Host "信息提取时间:" (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
  2. Write-Host ""
  3. # 获取操作系统信息
  4. $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
  5. Write-Host "系统版本:$($osInfo.Caption) $($osInfo.Version) 【 $($osInfo.OSArchitecture) 】"
  6. Write-Host "安装日期:$( $osInfo.InstallDate.ToString('yyyy-MM-dd') )"
  7. Write-Host ""
  8. # 获取产品信息
  9. $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct
  10. Write-Host "产品:"
  11. Write-Host "    供应商:" $productInfo.Vendor
  12. Write-Host "    系  列:" $productInfo.Name
  13. Write-Host "    型  号:" $productInfo.Version
  14. Write-Host "    序列号:" $productInfo.IdentifyingNumber
  15. Write-Host ""
  16. # 获取主板信息
  17. $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard
  18. Write-Host "主板:"
  19. Write-Host "    制造商:" $baseboardInfo.Manufacturer
  20. Write-Host "    产  品:" $baseboardInfo.Product
  21. Write-Host "    序列号:" $baseboardInfo.SerialNumber
  22. Write-Host ""
  23. # 获取处理器信息
  24. $processorInfo = Get-CimInstance -ClassName Win32_Processor
  25. Write-Host "CPU :【 $( ($processorInfo | Measure-Object).Count ) 颗 】"
  26. foreach ($processor in $processorInfo) {
  27.     Write-Host "    名  称: $($processor.Name) 【 $($processor.NumberOfCores) 核 $($processor.NumberOfLogicalProcessors) 线程 】"
  28.     Write-Host "    主  频:" $processor.MaxClockSpeed
  29. }
  30. Write-Host ""
  31. # 获取内存信息
  32. $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
  33. Write-Host "内存:【 $( ($memoryInfo | Measure-Object).Count ) 条 】"
  34. Write-Host "    总容量: $(($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB) GB"
  35. foreach ($memory in $memoryInfo) {
  36.     Write-Host "    内存: $($memory.Capacity / 1GB) GB"
  37.     Write-Host "        品    牌: $($memory.Manufacturer)"
  38.     Write-Host "        序 列 号: $($memory.SerialNumber)"
  39.     Write-Host "        最高频率: $($memory.Speed)"
  40. }
  41. Write-Host ""
  42. # 获取硬盘信息
  43. $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
  44. foreach ($disk in $diskInfo) {
  45.     $physicalDisk = Get-PhysicalDisk | Where-Object { $_.DeviceID -eq $disk.DeviceID.Substring(17) }
  46.     Add-Member -InputObject $disk -MemberType NoteProperty -Name BusType -Value $physicalDisk.BusType
  47. }
  48. Write-Host "硬盘:【 $( ($diskInfo | Measure-Object).Count ) 块 】"
  49. foreach ($disk in $diskInfo) {
  50.     Write-Host "    BusType: $($BusType)"
  51.     Write-Host "    硬  盘: $($disk.Model)"
  52.     Write-Host "    序列号: $($disk.SerialNumber)"
  53.     Write-Host "    容  量: $($disk.Size / 1GB) GB"
  54. }
  55. Write-Host ""
  56. # 获取显示信息
  57. $videoInfo = Get-CimInstance -ClassName Win32_VideoController
  58. Write-Host "显示:"
  59. foreach ($video in $videoInfo) {
  60.     Write-Host "    当前刷新率: "$video.CurrentRefreshRate
  61.     Write-Host "    最高刷新率: "$video.MaxRefreshRate
  62.     Write-Host "    显卡  名称: "$video.Name
  63.     Write-Host "    当前分辨率: "$video.VideoModeDescription
  64. }
  65. Write-Host ""
  66. # 获取BIOS信息
  67. $biosInfo = Get-CimInstance -ClassName Win32_BIOS
  68. Write-Host "BIOS:"
  69. Write-Host "    制  造  商: "$biosInfo.Manufacturer
  70. Write-Host "    名      称: "$biosInfo.Name
  71. Write-Host "    版      本: "$biosInfo.Version
  72. Write-Host "    BIOS  版本: "$biosInfo.BIOSVersion
  73. Write-Host "    SMBIOS版本: "$biosInfo.SMBIOSBIOSVersion
  74. Write-Host "    固件  日期: "$biosInfo.ReleaseDate.ToString('yyyy-MM-dd')
  75. Write-Host "    序  列  号: "$biosInfo.SerialNumber
  76. Write-Host ""
  77. pause
复制代码

TOP

返回列表