标题: [系统相关] 【wmic硬件检测-gfd5.3】新手发帖:简单获取电脑信息并保存,慢慢完善更新 [打印本页]
作者: gfd 时间: 2024-1-6 14:30 标题: 【wmic硬件检测-gfd5.3】新手发帖:简单获取电脑信息并保存,慢慢完善更新
本帖最后由 gfd 于 2024-1-17 11:54 编辑
我一直在用的代码,不定时更新。
主要用途:获取电脑的序列号、配置信息,然后保存到文件中。我是卖电脑的,收集这些信息可以记录电脑序列,销售日期,方便后期的保修查询等。
代码都是东拼西凑弄来的,大神有更好的建议欢迎提出,谢谢。- @echo off&color e&title gfd硬件检测_5.2
- mode con cols=110 lines=70
- setlocal enabledelayedexpansion
- echo 信息提取时间:%date% 时间 %Time%
- for /f "tokens=1* delims=:=" %%a in ('"wmic os get Caption,InstallDate,OSArchitecture,Version /Format:List"') do (
- IF /I "%%a"=="Caption" set Caption=%%b
- IF /I "%%a"=="InstallDate" set InstallDate=%%b
- IF /I "%%a"=="OSArchitecture" set OSArchitecture=%%b
- IF /I "%%a"=="Version" set Version=%%b
- )
- echo Windows_信息:%Caption%%Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
- echo.
-
- echo 主版:
- for /f "tokens=1* delims==" %%a in ('"wmic csproduct get IdentifyingNumber,Name,Vendor,Version /value|more +2"') do (
- IF /I "%%a"=="IdentifyingNumber" set IdentifyingNumber=%%b
- IF /I "%%a"=="Name" set Name=%%b
- IF /I "%%a"=="Vendor" set Vendor=%%b
- IF /I "%%a"=="Version" set VersionZ=%%b
- )
- echo 供应商:%Vendor%
- echo 系 列:%Name%
- echo 型 号:%VersionZ%
- echo 序列号:%IdentifyingNumber%&echo.&echo.
-
- REM 处理器
- for /f "tokens=2 delims==" %%a in ('"wmic cpu Get DeviceID /value"') do set /a CPUQuantity+=1
- echo CPU :【%CPUQuantity% 颗】
- for /f "tokens=1* delims==" %%a in ('"wmic cpu get MaxClockSpeed,Name,NumberOfCores,NumberOfLogicalProcessors /value"') do (
- IF /I "%%a"=="MaxClockSpeed" set MaxClockSpeed=%%b
- IF /I "%%a"=="Name" set NameC=%%b
- IF /I "%%a"=="NumberOfCores" set NumberOfCores=%%b
- IF /I "%%a"=="NumberOfLogicalProcessors" set NumberOfLogicalProcessors=%%b
- )
- echo 名 称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】
- echo 主 频:%MaxClockSpeed%&echo.&echo.
-
- REM 内存
- for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Tag /value"') do set /a MemoryQuantity+=1
- echo 内存:【%MemoryQuantity% 条】
- for /f "tokens=2 delims==" %%a in ('"wmic memorychip get Capacity /value"') do (
- set "Capacity=%%a"
- for /f "tokens=1 delims=." %%b in ("!Capacity:~,-7!/1073") do set /a m+=%%b
- )
- call echo 总容量:%%m%% GB
- for /f "tokens=1* delims==" %%a in ('"wmic memorychip get ConfiguredClockSpeed /value"') do (
- IF /I "%%a" == "ConfiguredClockSpeed" set ConfiguredClockSpeed=%%b
- )
- echo 频 率:%ConfiguredClockSpeed%&echo.&echo.
-
- REM 硬盘
- for /f "tokens=2 delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' get Caption /value"') do set /a DiskQuantity+=1
- echo 硬盘:【%DiskQuantity% 块】
- set "Model= 型 号:"&set "SerialNumber= 序列号:"&set "size= 容 量:"
- 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
-
-
- echo 显示:
- for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController get CurrentRefreshRate,DeviceID,MaxRefreshRate,MinRefreshRate,Name,VideoModeDescription /value"') do (
- IF /I "%%a"=="CurrentRefreshRate" (
- echo. 当前刷新率: %%b)
- IF /I "%%a"=="DeviceID" (
- echo. 设 备 ID: %%b)
- IF /I "%%a"=="MaxRefreshRate" (
- echo. 最高刷新率: %%b)
- IF /I "%%a"=="MinRefreshRate" (
- echo. 最低刷新率: %%b)
- IF /I "%%a"=="Name" (
- echo. 显卡 名称: %%b)
- IF /I "%%a"=="VideoModeDescription" (
- echo. 当前分辨率: %%b
- echo ----------------------------)
- )
- echo.&echo.
-
- echo BIOS:
- for /f "tokens=1* delims=:=" %%a in ('"wmic bios get BIOSVersion,Manufacturer,Name,ReleaseDate,SerialNumber,SMBIOSBIOSVersion,Version /Format:List"') do (
- IF /I "%%a"=="ReleaseDate" set ReleaseDate=%%b
- IF /I "%%a"=="SerialNumber" set SerialNumberB=%%b
- IF /I "%%a"=="Manufacturer" set Manufacturer=%%b
- IF /I "%%a"=="Name" set NameB=%%b
- IF /I "%%a"=="Version" set VersionB=%%b
- IF /I "%%a"=="BIOSVersion" set BIOSVersion=%%b
- IF /I "%%a"=="SMBIOSBIOSVersion" set SMBIOSBIOSVersion=%%b
- )
- echo 制 造 商:%Manufacturer%
- echo 名 称:%NameB%
- echo 版 本:%VersionB%
- echo BIOS 版本:%BIOSVersion%
- echo SMBIOS版本:%SMBIOSBIOSVersion%
- echo 固件 日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
- echo 序 列 号:%SerialNumberB%
-
- echo.
- echo 信息提取完成,按任意键保存到文本中。
- pause>nul
-
- REM ==========保存信息到文件中,如果不需要,删除下面所有==========
- echo 信息提取时间:%date% 时间 %Time%>>wmic硬件信息gfd.txt
- 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
- echo.>>wmic硬件信息gfd.txt
-
- echo 主版:>>wmic硬件信息gfd.txt
- echo 供应商:%Vendor%>>wmic硬件信息gfd.txt
- echo 系 列:%Name%>>wmic硬件信息gfd.txt
- echo 型 号:%VersionZ%>>wmic硬件信息gfd.txt
- echo 序列号:%IdentifyingNumber%>>wmic硬件信息gfd.txt
- echo. >>wmic硬件信息gfd.txt
- echo. >>wmic硬件信息gfd.txt
-
- REM 处理器
- echo CPU :【%CPUQuantity% 颗】>>wmic硬件信息gfd.txt
- echo 名 称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】>>wmic硬件信息gfd.txt
- echo 主 频:%MaxClockSpeed%>>wmic硬件信息gfd.txt
- echo. >>wmic硬件信息gfd.txt
- echo. >>wmic硬件信息gfd.txt
-
- REM 内存
- echo 内存:【%MemoryQuantity% 条】>>wmic硬件信息gfd.txt
- echo 总容量:%m% GB>>wmic硬件信息gfd.txt
- echo 频 率:%ConfiguredClockSpeed%>>wmic硬件信息gfd.txt
- echo. >>wmic硬件信息gfd.txt
- echo. >>wmic硬件信息gfd.txt
-
- REM 硬盘
- echo 硬盘:【%DiskQuantity% 块】>>wmic硬件信息gfd.txt
- set "Model= 型 号:"&set "SerialNumber= 序列号:"&set "size= 容 量:"
- 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
-
- echo 显示:>>wmic硬件信息gfd.txt
- for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController get CurrentRefreshRate,DeviceID,MaxRefreshRate,MinRefreshRate,Name,VideoModeDescription /value"') do (
- IF /I "%%a"=="CurrentRefreshRate" (
- echo. 当前刷新率: %%b>>wmic硬件信息gfd.txt)
- IF /I "%%a"=="DeviceID" (
- echo. 设 备 ID: %%b>>wmic硬件信息gfd.txt)
- IF /I "%%a"=="MaxRefreshRate" (
- echo. 最高刷新率: %%b>>wmic硬件信息gfd.txt)
- IF /I "%%a"=="MinRefreshRate" (
- echo. 最低刷新率: %%b>>wmic硬件信息gfd.txt)
- IF /I "%%a"=="Name" (
- echo. 显卡 名称: %%b>>wmic硬件信息gfd.txt)
- IF /I "%%a"=="VideoModeDescription" (
- echo. 当前分辨率: %%b>>wmic硬件信息gfd.txt
- echo ---------------------------->>wmic硬件信息gfd.txt)
- )
- echo. >>wmic硬件信息gfd.txt
- echo. >>wmic硬件信息gfd.txt
-
- echo BIOS:>>wmic硬件信息gfd.txt
- echo 制 造 商:%Manufacturer%>>wmic硬件信息gfd.txt
- echo 名 称:%NameB%>>wmic硬件信息gfd.txt
- echo 版 本:%VersionB%>>wmic硬件信息gfd.txt
- echo BIOS 版本:%BIOSVersion%>>wmic硬件信息gfd.txt
- echo SMBIOS版本:%SMBIOSBIOSVersion%>>wmic硬件信息gfd.txt
- echo 固件 日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日>>wmic硬件信息gfd.txt
- echo 序 列 号:%SerialNumberB%>>wmic硬件信息gfd.txt
- echo ****************************************页尾****************************************>>wmic硬件信息gfd.txt
复制代码
作者: gfd 时间: 2024-1-17 11:53
本帖最后由 gfd 于 2024-1-17 12:00 编辑
5.3更新
显示每条内存信息
显示每块硬盘信息(10进制截取GB容量)
代码如下:- @echo off&setlocal enabledelayedexpansion&title gfd硬件检测_5.3
-
- REM 日期时间
- for /f "tokens=1* delims=:=" %%a in ('"wmic os Get Caption,InstallDate,OSArchitecture,Version /value"') do (
- IF /I "%%a"=="Caption" set Caption=%%b
- IF /I "%%a"=="InstallDate" set InstallDate=%%b
- IF /I "%%a"=="OSArchitecture" set OSArchitecture=%%b
- IF /I "%%a"=="Version" set Version=%%b
- )
- echo 信息提取时间:%date% 时间 %Time%
- echo Windows_信息:%Caption%%Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
- echo.
-
- REM 产品 csproduct
- for /f "tokens=1* delims==" %%a in ('"wmic csproduct Get IdentifyingNumber,Name,Vendor,Version /value"') do (
- IF /I "%%a"=="IdentifyingNumber" set IdenCS=%%b
- IF /I "%%a"=="Name" set NameCS=%%b
- IF /I "%%a"=="Vendor" set VendCS=%%b
- IF /I "%%a"=="Version" set VersCS=%%b
- )
- REM 主板 baseboard
- for /f "tokens=1* delims=:=" %%i in ('"wmic baseboard get Manufacturer,Product,SerialNumber /value"') do (
- IF /I "%%i"=="Manufacturer" set ManuZB=%%j
- IF /I "%%i"=="Product" set ProdZB=%%j
- IF /I "%%i"=="SerialNumber" set SeriZB=%%j
- )
- REM 系统管理 ComputerSystem
- for /f "tokens=1* delims=:=" %%i in ('"wmic ComputerSystem get Manufacturer,SystemFamily,SystemSKUNumber /value"') do (
- IF /I "%%i"=="Manufacturer" set ManuSY=%%j
- IF /I "%%i"=="SystemFamily" set FamiSY=%%j
- IF /I "%%i"=="SystemSKUNumber" set SKUNSY=%%j
- )
- echo 产品:
- echo 供应商:%VendCS%
- echo 系 列:%NameCS%
- echo 型 号:%VersCS%
- echo 序列号:%IdenCS%
- echo 主板:
- echo 制造商:%ManuZB%
- echo 产 品:%ProdZB%
- echo 序列号:%SeriZB%
- echo System:
- echo 制造商:%ManuSY%
- echo 产品线:%FamiSY%
- echo 序列号:%SKUNSY%&echo.&echo.
-
- REM 处理器
- for /f "tokens=2 delims==" %%a in ('"wmic cpu Get DeviceID /value"') do set /a CPUQuantity+=1
- for /f "tokens=1* delims==" %%a in ('"wmic cpu Get MaxClockSpeed,Name,NumberOfCores,NumberOfLogicalProcessors /value"') do (
- IF /I "%%a"=="MaxClockSpeed" set MaxClockSpeed=%%b
- IF /I "%%a"=="Name" set NameC=%%b
- IF /I "%%a"=="NumberOfCores" set NumberOfCores=%%b
- IF /I "%%a"=="NumberOfLogicalProcessors" set NumberOfLogicalProcessors=%%b
- )
- echo CPU :【%CPUQuantity% 颗】
- echo 名 称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】
- echo 主 频:%MaxClockSpeed%&echo.&echo.
-
- REM 内存
- for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Tag /value"') do set /a MemoryQuantity+=1
- for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Capacity /value"') do (
- set Capacity=%%a
- set /a NCG=!Capacity:~,-7!/1073
- set /a m+=!NCG!
- )
- for /f "tokens=1* delims==" %%a in ('"wmic memorychip where Tag='Physical Memory 0' Get ConfiguredClockSpeed /value"') do (
- IF /I "%%a"=="ConfiguredClockSpeed" set ConfiguredClockSpeed=%%b
- )
- echo 内存:【%MemoryQuantity% 条】
- echo 总容量:!m! GB 【当前频率:%ConfiguredClockSpeed% MHz】
- echo ----------------------------
- for /f "tokens=1* delims==" %%a in ('"wmic memorychip Get Capacity,Manufacturer,SerialNumber,Speed /value"') do (
- IF /I "%%a"=="Capacity" (
- set Capacity=%%b
- set /a NCG=!Capacity:~,-7!/1073
- set /a NC+=1
- echo. 内存!NC! :%NCG% GB)
- IF /I "%%a"=="Manufacturer" (
- echo. 品 牌:%%b)
- IF /I "%%a"=="SerialNumber" (
- echo. 序 列 号:%%b)
- IF /I "%%a"=="Speed" (
- echo. 最高频率:%%b
- echo ----------------------------)
- )
- echo.&echo.
-
- REM 硬盘
- for /f "tokens=2 delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Caption /value"') do set /a DiskQuantity+=1
- echo 硬盘:【%DiskQuantity% 块】
- for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Model,SerialNumber,Size /value"') do (
- IF /I "%%a"=="Model" (
- set /a YP+=1
- echo. 硬盘 !YP!:%%b)
- IF /I "%%a"=="SerialNumber" (
- echo. 序列号:%%b)
- IF /I "%%a"=="Size" (
- set Size=%%b
- echo. 容 量:!Size:~,-10! GB
- echo ----------------------------)
- )
- echo.&echo.
-
-
- echo 显示:
- for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController Get CurrentRefreshRate,MaxRefreshRate,Name,VideoModeDescription /value"') do (
- IF /I "%%a"=="CurrentRefreshRate" (
- echo. 当前刷新率: %%b)
- IF /I "%%a"=="MaxRefreshRate" (
- echo. 最高刷新率: %%b)
- IF /I "%%a"=="Name" (
- echo. 显卡 名称: %%b)
- IF /I "%%a"=="VideoModeDescription" (
- echo. 当前分辨率: %%b
- echo ----------------------------)
- )
- echo.&echo.
-
- REM BIOS
- for /f "tokens=1* delims=:=" %%a in ('"wmic bios Get BIOSVersion,Manufacturer,Name,ReleaseDate,SerialNumber,SMBIOSBIOSVersion,Version /value"') do (
- IF /I "%%a"=="ReleaseDate" set ReleaseDate=%%b
- IF /I "%%a"=="SerialNumber" set SeriBI=%%b
- IF /I "%%a"=="Manufacturer" set ManuBI=%%b
- IF /I "%%a"=="Name" set NameBI=%%b
- IF /I "%%a"=="Version" set VersBI=%%b
- IF /I "%%a"=="BIOSVersion" set BIOSVersion=%%b
- IF /I "%%a"=="SMBIOSBIOSVersion" set SMBIOSBIOSVersion=%%b
- )
- echo BIOS:
- echo 制 造 商:%ManuBI%
- echo 名 称:%NameBI%
- echo 版 本:%VersBI%
- echo BIOS 版本:%BIOSVersion%
- echo SMBIOS版本:%SMBIOSBIOSVersion%
- echo 固件 日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
- echo 序 列 号:%SeriBI%
- echo.
-
- echo 信息提取完成,按任意键保存到文本中。
- pause>nul
-
- REM ==========保存信息到文件中,如果不需要,删除下面所有==========
- (echo 信息提取时间:%date% 时间 %Time%
- echo Windows_信息:%Caption%%Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
- echo.
- echo 产品:
- echo 供应商:%VendCS%
- echo 系 列:%NameCS%
- echo 型 号:%VersCS%
- echo 序列号:%IdenCS%
- echo 主板:
- echo 制造商:%ManuZB%
- echo 产 品:%ProdZB%
- echo 序列号:%SeriZB%
- echo System:
- echo 制造商:%ManuSY%
- echo 产品线:%FamiSY%
- echo 序列号:%SKUNSY%
- echo.)>>硬件信息gfd5.txt
- echo CPU :【%CPUQuantity% 颗】>>硬件信息gfd5.txt
- echo 名 称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】>>硬件信息gfd5.txt
- echo 主 频:%MaxClockSpeed%>>硬件信息gfd5.txt
- echo.>>硬件信息gfd5.txt
- echo 内存:【%MemoryQuantity% 条】>>硬件信息gfd5.txt
- echo 总容量:%m% GB 【当前频率:%ConfiguredClockSpeed% MHz】>>硬件信息gfd5.txt
- echo ---------------------------->>硬件信息gfd5.txt
- for /f "tokens=1* delims==" %%a in ('"wmic memorychip Get Capacity,Manufacturer,SerialNumber,Speed /value"') do (
- IF /I "%%a"=="Capacity" (
- set CapaTXT=%%b
- set /a NCG=!CapaTXT:~,-7!/1073
- set /a NCTXT+=1
- echo. 内存!NCTXT! :%NCG% GB>>硬件信息gfd5.txt)
- IF /I "%%a"=="Manufacturer" (
- echo. 品 牌:%%b>>硬件信息gfd5.txt)
- IF /I "%%a"=="SerialNumber" (
- echo. 序 列 号:%%b>>硬件信息gfd5.txt)
- IF /I "%%a"=="Speed" (
- echo. 最高频率:%%b>>硬件信息gfd5.txt
- echo ---------------------------->>硬件信息gfd5.txt))
- (echo.
- echo 硬盘:【%DiskQuantity% 块】)>>硬件信息gfd5.txt
- for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Model,SerialNumber,Size /value"') do (
- IF /I "%%a"=="Model" (
- set /a YPTXT+=1
- echo. 硬盘 !YPTXT!:%%b>>硬件信息gfd5.txt)
- IF /I "%%a"=="SerialNumber" (
- echo. 序列号:%%b>>硬件信息gfd5.txt)
- IF /I "%%a"=="Size" (
- set Size=%%b
- echo. 容 量:!Size:~,-10! GB>>硬件信息gfd5.txt
- echo ---------------------------->>硬件信息gfd5.txt))
- (echo.
- echo 显示:)>>硬件信息gfd5.txt
- for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController Get CurrentRefreshRate,MaxRefreshRate,Name,VideoModeDescription /value"') do (
- IF /I "%%a"=="CurrentRefreshRate" (
- echo. 当前刷新率: %%b>>硬件信息gfd5.txt)
- IF /I "%%a"=="MaxRefreshRate" (
- echo. 最高刷新率: %%b>>硬件信息gfd5.txt)
- IF /I "%%a"=="Name" (
- echo. 显卡 名称: %%b>>硬件信息gfd5.txt)
- IF /I "%%a"=="VideoModeDescription" (
- echo. 当前分辨率: %%b>>硬件信息gfd5.txt
- echo ---------------------------->>硬件信息gfd5.txt))
- (echo.
- echo BIOS:
- echo 制 造 商:%ManuBI%
- echo 名 称:%NameBI%
- echo 版 本:%VersBI%
- echo BIOS 版本:%BIOSVersion%
- echo SMBIOS版本:%SMBIOSBIOSVersion%
- echo 固件 日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
- echo 序 列 号:%SeriBI%
- echo ****************************************页尾****************************************
- )>>硬件信息gfd5.txt
- echo.&echo 已保存,稍后自动退出。&echo.
- timeout /T 3 >nul
复制代码
作者: newswan 时间: 2024-1-17 12:31
回复 1# gfd
建议改成 powershell
作者: gfd 时间: 2024-1-17 14:37
回复 3# newswan
不太会,我是个半吊子,大部分都是抄袭拼凑的。您要是方便给改改,谢谢
作者: ppll2030 时间: 2024-1-17 15:16
如果有显示器+打印机等设备信息,就适合单位资产清点了。
作者: newswan 时间: 2024-1-17 16:23
回复 4# gfd
晚点试试ai
作者: newswan 时间: 2024-1-17 16:24
回复 5# ppll2030
有资产管理软件,aida64 也许可以
作者: gfd 时间: 2024-1-17 16:58
回复 5# ppll2030
http://www.bathome.net/thread-38259-1-1.html
这个有打印机 显示器。dx获取到的 时间久点
作者: newswan 时间: 2024-1-17 17:36
- PowerShell脚本相对于批处理脚本具有许多优势和劣势。
-
- 优势:
-
- 强大的对象模型:PowerShell是基于对象的脚本语言,可以轻松地处理和操作对象,而不仅仅是文本流。
- 内置的.NET集成:PowerShell可以直接访问.NET Framework,因此可以利用.NET库中的丰富功能。
- 更丰富的功能:PowerShell具有更多的内置功能和命令,可以更轻松地执行系统管理任务。
- 更好的错误处理:PowerShell提供了更强大的错误处理和调试功能,使得编写和调试脚本更加容易。
- 更好的安全性:PowerShell具有更多的安全功能和策略,可以更好地控制脚本的执行和访问权限。
- 劣势:
-
- 学习曲线:对于习惯了批处理脚本的用户来说,学习PowerShell可能需要一些时间。
- 兼容性:某些较旧的Windows系统可能不支持PowerShell,因此在这些系统上可能无法运行PowerShell脚本。
- 执行速度:相对于简单的批处理脚本,PowerShell脚本可能会有更长的启动时间和执行时间。
- 总的来说,PowerShell脚本在系统管理和自动化方面具有更多的优势,但对于简单的任务和较旧的系统,批处理脚本可能仍然是一个更简单和直接的选择。
复制代码
作者: newswan 时间: 2024-1-17 17:37
- # 获取操作系统信息
- $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object Caption, InstallDate, OSArchitecture, Version
- $osInfo.InstallDate = $osInfo.InstallDate.ToString("yyyyMMddHHmmss")
- Write-Host "信息提取时间:" (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
- 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) + "秒"
- Write-Host ""
-
- # 获取产品信息
- $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct | Select-Object IdentifyingNumber, Name, Vendor, Version
- Write-Host "产品:"
- Write-Host " 供应商:" $productInfo.Vendor
- Write-Host " 系 列:" $productInfo.Name
- Write-Host " 型 号:" $productInfo.Version
- Write-Host " 序列号:" $productInfo.IdentifyingNumber
- Write-Host ""
-
- # 获取主板信息
- $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard | Select-Object Manufacturer, Product, SerialNumber
- Write-Host "主板:"
- Write-Host " 制造商:" $baseboardInfo.Manufacturer
- Write-Host " 产 品:" $baseboardInfo.Product
- Write-Host " 序列号:" $baseboardInfo.SerialNumber
- Write-Host ""
-
- # 获取处理器信息
- $processorInfo = Get-CimInstance -ClassName Win32_Processor | Select-Object Name, MaxClockSpeed, NumberOfCores, NumberOfLogicalProcessors
- Write-Host "CPU :【" + ($processorInfo.Count) + " 颗】"
- foreach ($processor in $processorInfo) {
- Write-Host " 名 称:" $processor.Name + "【" + $processor.NumberOfCores + "核" + $processor.NumberOfLogicalProcessors + "线程】"
- Write-Host " 主 频:" $processor.MaxClockSpeed
- }
- Write-Host ""
-
- # 获取内存信息
- $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
- Write-Host "内存:【" + ($memoryInfo.Count) + " 条】"
- $totalMemory = ($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB
- Write-Host " 总容量:" $totalMemory "GB"
- foreach ($memory in $memoryInfo) {
- Write-Host " 内存:" ($memory.Capacity / 1GB) "GB"
- Write-Host " 品 牌:" $memory.Manufacturer
- Write-Host " 序 列 号:" $memory.SerialNumber
- Write-Host " 最高频率:" $memory.Speed
- }
- Write-Host ""
-
- # 获取硬盘信息
- $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
- Write-Host "硬盘:【" + ($diskInfo.Count) + " 块】"
- foreach ($disk in $diskInfo) {
- Write-Host " 硬盘:" $disk.Model
- Write-Host " 序列号:" $disk.SerialNumber
- Write-Host " 容 量:" ($disk.Size / 1GB) "GB"
- }
- Write-Host ""
-
- # 获取显示信息
- $videoInfo = Get-CimInstance -ClassName Win32_VideoController | Select-Object CurrentRefreshRate, MaxRefreshRate, Name, VideoModeDescription
- Write-Host "显示:"
- foreach ($video in $videoInfo) {
- Write-Host " 当前刷新率:" $video.CurrentRefreshRate
- Write-Host " 最高刷新率:" $video.MaxRefreshRate
- Write-Host " 显卡 名称:" $video.Name
- Write-Host " 当前分辨率:" $video.VideoModeDescription
- }
- Write-Host ""
-
- # 获取BIOS信息
- $biosInfo = Get-CimInstance -ClassName Win32_BIOS | Select-Object BIOSVersion, Manufacturer, Name, ReleaseDate, SerialNumber, SMBIOSBIOSVersion, Version
- $biosInfo.ReleaseDate = $biosInfo.ReleaseDate.ToString("yyyyMMdd")
- Write-Host "BIOS:"
- Write-Host " 制 造 商:" $biosInfo.Manufacturer
- Write-Host " 名 称:" $biosInfo.Name
- Write-Host " 版 本:" $biosInfo.Version
- Write-Host " BIOS 版本:" $biosInfo.BIOSVersion
- Write-Host " SMBIOS版本:" $biosInfo.SMBIOSBIOSVersion
- Write-Host " 固件 日期:" $biosInfo.ReleaseDate.Substring(0, 4) + "年" + $biosInfo.ReleaseDate.Substring(4, 2) + "月" + $biosInfo.ReleaseDate.Substring(6, 2) + "日"
- Write-Host " 序 列 号:" $biosInfo.SerialNumber
复制代码
作者: newswan 时间: 2024-1-17 17:38
上面的是 ai 改写的
作者: newswan 时间: 2024-1-17 20:06
整理过的- Write-Host "信息提取时间:" (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
- Write-Host ""
-
- # 获取操作系统信息
- $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
- Write-Host "系统版本:$($osInfo.Caption) $($osInfo.Version) 【 $($osInfo.OSArchitecture) 】"
- Write-Host "安装日期:$( $osInfo.InstallDate.ToString('yyyy-MM-dd') )"
- Write-Host ""
-
- # 获取产品信息
- $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct
- Write-Host "产品:"
- Write-Host " 供应商:" $productInfo.Vendor
- Write-Host " 系 列:" $productInfo.Name
- Write-Host " 型 号:" $productInfo.Version
- Write-Host " 序列号:" $productInfo.IdentifyingNumber
- Write-Host ""
-
- # 获取主板信息
- $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard
- Write-Host "主板:"
- Write-Host " 制造商:" $baseboardInfo.Manufacturer
- Write-Host " 产 品:" $baseboardInfo.Product
- Write-Host " 序列号:" $baseboardInfo.SerialNumber
- Write-Host ""
-
- # 获取处理器信息
- $processorInfo = Get-CimInstance -ClassName Win32_Processor
- Write-Host "CPU :【 $( ($processorInfo | Measure-Object).Count ) 颗 】"
- foreach ($processor in $processorInfo) {
- Write-Host " 名 称: $($processor.Name) 【 $($processor.NumberOfCores) 核 $($processor.NumberOfLogicalProcessors) 线程 】"
- Write-Host " 主 频:" $processor.MaxClockSpeed
- }
- Write-Host ""
-
- # 获取内存信息
- $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
- Write-Host "内存:【 $( ($memoryInfo | Measure-Object).Count ) 条 】"
- Write-Host " 总容量: $(($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB) GB"
- foreach ($memory in $memoryInfo) {
- Write-Host " 内存: $($memory.Capacity / 1GB) GB"
- Write-Host " 品 牌: $($memory.Manufacturer)"
- Write-Host " 序 列 号: $($memory.SerialNumber)"
- Write-Host " 最高频率: $($memory.Speed)"
- }
- Write-Host ""
-
- # 获取硬盘信息
- $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
- Write-Host "硬盘:【 $( ($diskInfo | Measure-Object).Count ) 块 】"
- foreach ($disk in $diskInfo) {
- Write-Host " 硬盘: $($disk.Model)"
- Write-Host " 序列号: $($disk.SerialNumber)"
- Write-Host " 容 量: $($disk.Size / 1GB) GB"
- }
- Write-Host ""
-
- # 获取显示信息
- $videoInfo = Get-CimInstance -ClassName Win32_VideoController
- Write-Host "显示:"
- foreach ($video in $videoInfo) {
- Write-Host " 当前刷新率: "$video.CurrentRefreshRate
- Write-Host " 最高刷新率: "$video.MaxRefreshRate
- Write-Host " 显卡 名称: "$video.Name
- Write-Host " 当前分辨率: "$video.VideoModeDescription
- }
- Write-Host ""
-
- # 获取BIOS信息
- $biosInfo = Get-CimInstance -ClassName Win32_BIOS
- Write-Host "BIOS:"
- Write-Host " 制 造 商: "$biosInfo.Manufacturer
- Write-Host " 名 称: "$biosInfo.Name
- Write-Host " 版 本: "$biosInfo.Version
- Write-Host " BIOS 版本: "$biosInfo.BIOSVersion
- Write-Host " SMBIOS版本: "$biosInfo.SMBIOSBIOSVersion
- Write-Host " 固件 日期: "$biosInfo.ReleaseDate.ToString('yyyy-MM-dd')
- Write-Host " 序 列 号: "$biosInfo.SerialNumber
- Write-Host ""
-
- pause
复制代码
作者: gfd 时间: 2024-1-17 20:17
回复 12# newswan
谢谢,我试试。
作者: gfd 时间: 2024-1-17 20:23
本帖最后由 gfd 于 2024-1-17 20:26 编辑
回复 12# newswan
很好。
获取时间比批处理慢一些。
内存和硬盘不显示序列号(硬盘1、硬盘2……)再加上判定硬盘机械?固态?
能不能获取显卡显存容量(cmd显存最大4G),还有显示器品牌型号的信息
怎么保存到文件中?
作者: newswan 时间: 2024-1-17 20:52
加 nvme 识别- Write-Host "信息提取时间:" (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
- Write-Host ""
-
- # 获取操作系统信息
- $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
- Write-Host "系统版本:$($osInfo.Caption) $($osInfo.Version) 【 $($osInfo.OSArchitecture) 】"
- Write-Host "安装日期:$( $osInfo.InstallDate.ToString('yyyy-MM-dd') )"
- Write-Host ""
-
- # 获取产品信息
- $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct
- Write-Host "产品:"
- Write-Host " 供应商:" $productInfo.Vendor
- Write-Host " 系 列:" $productInfo.Name
- Write-Host " 型 号:" $productInfo.Version
- Write-Host " 序列号:" $productInfo.IdentifyingNumber
- Write-Host ""
-
- # 获取主板信息
- $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard
- Write-Host "主板:"
- Write-Host " 制造商:" $baseboardInfo.Manufacturer
- Write-Host " 产 品:" $baseboardInfo.Product
- Write-Host " 序列号:" $baseboardInfo.SerialNumber
- Write-Host ""
-
- # 获取处理器信息
- $processorInfo = Get-CimInstance -ClassName Win32_Processor
- Write-Host "CPU :【 $( ($processorInfo | Measure-Object).Count ) 颗 】"
- foreach ($processor in $processorInfo) {
- Write-Host " 名 称: $($processor.Name) 【 $($processor.NumberOfCores) 核 $($processor.NumberOfLogicalProcessors) 线程 】"
- Write-Host " 主 频:" $processor.MaxClockSpeed
- }
- Write-Host ""
-
- # 获取内存信息
- $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
- Write-Host "内存:【 $( ($memoryInfo | Measure-Object).Count ) 条 】"
- Write-Host " 总容量: $(($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB) GB"
- foreach ($memory in $memoryInfo) {
- Write-Host " 内存: $($memory.Capacity / 1GB) GB"
- Write-Host " 品 牌: $($memory.Manufacturer)"
- Write-Host " 序 列 号: $($memory.SerialNumber)"
- Write-Host " 最高频率: $($memory.Speed)"
- }
- Write-Host ""
-
- # 获取硬盘信息
- $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
- foreach ($disk in $diskInfo) {
- $physicalDisk = Get-PhysicalDisk | Where-Object { $_.DeviceID -eq $disk.DeviceID.Substring(17) }
- Add-Member -InputObject $disk -MemberType NoteProperty -Name BusType -Value $physicalDisk.BusType
- }
- Write-Host "硬盘:【 $( ($diskInfo | Measure-Object).Count ) 块 】"
- foreach ($disk in $diskInfo) {
- Write-Host " BusType: $($BusType)"
- Write-Host " 硬 盘: $($disk.Model)"
- Write-Host " 序列号: $($disk.SerialNumber)"
- Write-Host " 容 量: $($disk.Size / 1GB) GB"
- }
- Write-Host ""
-
- # 获取显示信息
- $videoInfo = Get-CimInstance -ClassName Win32_VideoController
- Write-Host "显示:"
- foreach ($video in $videoInfo) {
- Write-Host " 当前刷新率: "$video.CurrentRefreshRate
- Write-Host " 最高刷新率: "$video.MaxRefreshRate
- Write-Host " 显卡 名称: "$video.Name
- Write-Host " 当前分辨率: "$video.VideoModeDescription
- }
- Write-Host ""
-
- # 获取BIOS信息
- $biosInfo = Get-CimInstance -ClassName Win32_BIOS
- Write-Host "BIOS:"
- Write-Host " 制 造 商: "$biosInfo.Manufacturer
- Write-Host " 名 称: "$biosInfo.Name
- Write-Host " 版 本: "$biosInfo.Version
- Write-Host " BIOS 版本: "$biosInfo.BIOSVersion
- Write-Host " SMBIOS版本: "$biosInfo.SMBIOSBIOSVersion
- Write-Host " 固件 日期: "$biosInfo.ReleaseDate.ToString('yyyy-MM-dd')
- Write-Host " 序 列 号: "$biosInfo.SerialNumber
- Write-Host ""
-
- pause
复制代码
作者: newswan 时间: 2024-1-17 21:28
复制代码
作者: newswan 时间: 2024-1-17 21:28
可以保存文件,其他有空了再来
作者: newswan 时间: 2024-1-18 13:37
复制代码
作者: gfd 时间: 2024-1-18 13:44
回复 18# newswan
谢谢,我学习学习。
作者: yl19850329 时间: 2024-10-16 10:35
运行环境,收集局域网内所有电脑配置(批处理放置在共享文件夹内,双击运行之后把生成的电脑配置文件复制到共享文件夹内。)(问题,按任意键保存时批处理不自动关闭。麻烦给修改一下。)- @echo off&setlocal enabledelayedexpansion&title gfd硬件检测_5.3
-
- REM 日期时间
- for /f "tokens=1* delims=:=" %%a in ('"wmic os Get Caption,InstallDate,OSArchitecture,Version /value"') do (
- IF /I "%%a"=="Caption" set Caption=%%b
- IF /I "%%a"=="InstallDate" set InstallDate=%%b
- IF /I "%%a"=="OSArchitecture" set OSArchitecture=%%b
- IF /I "%%a"=="Version" set Version=%%b
- )
- echo 信息提取时间:%date% 时间 %Time%
- echo Windows_信息:%Caption% %Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
- echo.
-
- REM 产品 csproduct
- for /f "tokens=1* delims==" %%a in ('"wmic csproduct Get IdentifyingNumber,Name,Vendor,Version /value"') do (
- IF /I "%%a"=="IdentifyingNumber" set IdenCS=%%b
- IF /I "%%a"=="Name" set NameCS=%%b
- IF /I "%%a"=="Vendor" set VendCS=%%b
- IF /I "%%a"=="Version" set VersCS=%%b
- )
- REM 主板 baseboard
- for /f "tokens=1* delims=:=" %%i in ('"wmic baseboard get Manufacturer,Product,SerialNumber /value"') do (
- IF /I "%%i"=="Manufacturer" set ManuZB=%%j
- IF /I "%%i"=="Product" set ProdZB=%%j
- IF /I "%%i"=="SerialNumber" set SeriZB=%%j
- )
- REM 系统管理 ComputerSystem
- for /f "tokens=1* delims=:=" %%i in ('"wmic ComputerSystem get Manufacturer,SystemFamily,SystemSKUNumber /value"') do (
- IF /I "%%i"=="Manufacturer" set ManuSY=%%j
- IF /I "%%i"=="SystemFamily" set FamiSY=%%j
- IF /I "%%i"=="SystemSKUNumber" set SKUNSY=%%j
- )
- echo 计算机名: %computername%
- echo 主板出厂日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
- echo 主板型号:%ManuZB% %ProdZB% 序列号:%SeriZB%
-
- REM 处理器
- for /f "tokens=2 delims==" %%a in ('"wmic cpu Get DeviceID /value"') do set /a CPUQuantity+=1
- for /f "tokens=1* delims==" %%a in ('"wmic cpu Get MaxClockSpeed,Name,NumberOfCores,NumberOfLogicalProcessors /value"') do (
- IF /I "%%a"=="MaxClockSpeed" set MaxClockSpeed=%%b
- IF /I "%%a"=="Name" set NameC=%%b
- IF /I "%%a"=="NumberOfCores" set NumberOfCores=%%b
- IF /I "%%a"=="NumberOfLogicalProcessors" set NumberOfLogicalProcessors=%%b
- )
- echo CPU :【%CPUQuantity% 颗】
- echo 名 称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】
-
- REM 内存
- for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Tag /value"') do set /a MemoryQuantity+=1
- for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Capacity /value"') do (
- set Capacity=%%a
- set /a NCG=!Capacity:~,-7!/1073
- set /a m+=!NCG!
- )
- for /f "tokens=1* delims==" %%a in ('"wmic memorychip where Tag='Physical Memory 0' Get ConfiguredClockSpeed /value"') do (
- IF /I "%%a"=="ConfiguredClockSpeed" set ConfiguredClockSpeed=%%b
- )
- echo 内存:【%MemoryQuantity% 条】
- echo 总容量:!m! GB 【当前频率:%ConfiguredClockSpeed% MHz】
- echo ----------------------------
- for /f "tokens=1* delims==" %%a in ('"wmic memorychip Get Capacity,Manufacturer,SerialNumber,Speed /value"') do (
- IF /I "%%a"=="Capacity" (
- set Capacity=%%b
- set /a NCG=!Capacity:~,-7!/1073
- set /a NC+=1
- echo. 内存!NC! :%NCG% GB)
- IF /I "%%a"=="Manufacturer" (
- echo. 品 牌:%%b)
- IF /I "%%a"=="SerialNumber" (
- echo. 序 列 号:%%b)
- IF /I "%%a"=="Speed" (
- echo. 最高频率:%%b
- echo ----------------------------)
- )
- echo.&echo.
-
- REM 硬盘
- for /f "tokens=2 delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Caption /value"') do set /a DiskQuantity+=1
- echo 硬盘:【%DiskQuantity% 块】
- for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Model,SerialNumber,Size /value"') do (
- IF /I "%%a"=="Model" (
- set /a YP+=1
- echo. 硬盘 !YP!:%%b)
- IF /I "%%a"=="SerialNumber" (
- echo. 序列号:%%b)
- IF /I "%%a"=="Size" (
- set Size=%%b
- echo. 容 量:!Size:~,-10! GB
- echo ----------------------------)
- )
- echo.&echo.
-
- REM BIOS
- for /f "tokens=1* delims=:=" %%a in ('"wmic bios Get BIOSVersion,Manufacturer,Name,ReleaseDate,SerialNumber,SMBIOSBIOSVersion,Version /value"') do (
- IF /I "%%a"=="ReleaseDate" set ReleaseDate=%%b
- IF /I "%%a"=="SerialNumber" set SeriBI=%%b
- IF /I "%%a"=="Manufacturer" set ManuBI=%%b
- IF /I "%%a"=="Name" set NameBI=%%b
- IF /I "%%a"=="Version" set VersBI=%%b
- IF /I "%%a"=="BIOSVersion" set BIOSVersion=%%b
- IF /I "%%a"=="SMBIOSBIOSVersion" set SMBIOSBIOSVersion=%%b
- )
- echo.
-
- echo 信息提取完成,按任意键保存到文本中。
- pause>nul
-
- REM ==========保存信息到文件中,如果不需要,删除下面所有==========
- set dept=部门名-测试名
- (echo 信息提取时间:%date% 时间 %Time%
- echo Windows_信息:%Caption% %Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
- echo.
- echo 计算机名: %computername%
- echo 主板出厂日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
- echo 主板型号:%ManuZB% %ProdZB% 序列号:%SeriZB%
- echo.)>>"!dept!-%computername%.txt"
- echo CPU :【%CPUQuantity% 颗】>>"!dept!-%computername%.txt"
- echo 名 称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】>>"!dept!-%computername%.txt"
- echo.>>"!dept!-%computername%.txt"
- echo 内存:【%MemoryQuantity% 条】>>"!dept!-%computername%.txt"
- echo 总容量:%m% GB 【当前频率:%ConfiguredClockSpeed% MHz】>>"!dept!-%computername%.txt"
- echo ---------------------------->>"!dept!-%computername%.txt"
- for /f "tokens=1* delims==" %%a in ('"wmic memorychip Get Capacity,Manufacturer,SerialNumber,Speed /value"') do (
- IF /I "%%a"=="Capacity" (
- set CapaTXT=%%b
- set /a NCG=!CapaTXT:~,-7!/1073
- set /a NCTXT+=1
- echo. 内存!NCTXT! :%NCG% GB>>"!dept!-%computername%.txt")
- IF /I "%%a"=="Manufacturer" (
- echo. 品 牌:%%b>>"!dept!-%computername%.txt")
- IF /I "%%a"=="SerialNumber" (
- echo. 序 列 号:%%b>>"!dept!-%computername%.txt")
- IF /I "%%a"=="Speed" (
- echo. 最高频率:%%b>>"!dept!-%computername%.txt"
- echo ---------------------------->>"!dept!-%computername%.txt"))
- (echo.
- echo 硬盘:【%DiskQuantity% 块】)>>"!dept!-%computername%.txt"
- for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Model,SerialNumber,Size /value"') do (
- IF /I "%%a"=="Model" (
- set /a YPTXT+=1
- echo. 硬盘 !YPTXT!:%%b>>"!dept!-%computername%.txt")
- IF /I "%%a"=="SerialNumber" (
- echo. 序列号:%%b>>"!dept!-%computername%.txt")
- IF /I "%%a"=="Size" (
- set Size=%%b
- echo. 容 量:!Size:~,-10! GB>>"!dept!-%computername%.txt"
- echo ---------------------------->>"!dept!-%computername%.txt"))
- (echo.
- echo ****************************************页尾****************************************
- )>>"!dept!-%computername%.txt"
- xcopy /s /y c:\windows\%dept%-%computername%.txt \\win2008r2\硬件信息\
- echo.&echo 已保存,稍后自动退出。&echo.
- timeout /T 3 >nul
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |