Imports System
Imports SystemManagement
Module Module1
Sub Main()
Dim scope As New ManagementScope("\\\root\cimv2")
scopeConnect()
Dim objectQuery As New ObjectQuery("SELECT FROM Win32_Processor")
Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
Dim cpu As ManagementObject
For Each cpu In searcherGet()
ConsoleWriteLine("Processor: " & cpu("Name"))
ConsoleWriteLine("Manufacturer: " & cpu("Manufacturer"))
ConsoleWriteLine("Clock frequency: " & cpu("MaxClockSpeed") & " MHz")
ConsoleWriteLine("NumberOfLogicalProcessors: " & cpu("NumberOfLogicalProcessors"))
ConsoleWriteLine("NumberOfCores: " & cpu("NumberOfCores"))
ConsoleWriteLine()
Next cpu
ConsoleWriteLine()
ConsoleWriteLine("Press any key to quit")
ConsoleReadKey()
End Sub
End Module
@echo off
chcp 936>nul 2>nul
setlocal enabledelayedexpansion
set /p name=姓名:
set /p type=类型:
set /p use=用途:
@echo 名称: %name% >%name%txt
@echo 类型: %type% >>%name%txt
@echo 用途: %use% >>%name%txt
@echo>>%name%txt
@echo
@rem 电脑名称 制造商
for /f "tokens=1-2 delims==" %%a in ('wmic computersystem get Name^,Manufacturer /value') do (
for /f %%i in ("%%a") do (
if "%%i" == "Name" (
@echo 电脑名称: %%b
set str=%%b
@echo 电脑名称: !str:~0,-1!>>%name%txt
)
if "%%i" == "Manufacturer" (
@echo 制造商: %%b
set str=%%b
@echo 制造商: !str:~0,-1!>>%name%txt
)
)
)
@rem *** 作系统
for /f "tokens= delims=" %%a in ('wmic os get Caption /value') do (
for /f %%i in ("%%a") do (
if "%%i" == "Caption" (
@echo *** 作系统: %%b
set str=%%b
@echo *** 作系统: !str:~0,-1!>>%name%txt
)
)
)
@echo>>%name%txt
@echo
@rem IP MAC
for /f "tokens=1-2 delims==" %%a in ('wmic nicconfig where "IPEnabled='TRUE'" get IPAddress^,MACAddress /value') do (
for /f %%i in ("%%a") do (
if "%%i" == "IPAddress" (
for /f tokens^=1-3^ delims^={^" %%x in ("%%b") do (
@echo IP地址: %%x
@echo IP地址: %%x>>%name%txt
)
)
if "%%i" == "MACAddress" (
@echo MAC地址: %%b
@echo MAC地址: !str:~0,-1!>>%name%txt
)
)
)
@echo>>%name%txt
@echo
@rem CPU型号 CPU核数 CPU线程数
for /f "tokens=1-2 delims==" %%a in ('wmic cpu get Name^,NumberOfCores^,NumberOfLogicalProcessors /value') do (
for /f %%i in ("%%a") do (
if "%%i" == "Name" (
@echo CPU型号: %%b
set str=%%b
@echo CPU型号: !str:~0,-1!>>%name%txt
)
if "%%i" == "NumberOfCores" (
@echo CPU核数: %%b
set str=%%b
@echo CPU核数: !str:~0,-1!>>%name%txt
)
if "%%i" == "NumberOfLogicalProcessors" (
@echo CPU线程数: %%b
set str=%%b
@echo CPU线程数: !str:~0,-1!>>%name%txt
)
)
)
@echo>>%name%txt
@echo
@rem 内存型号 内存大小
for /f "tokens=1-2 delims==" %%a in ('wmic memorychip get PartNumber^,Capacity /value') do (
for /f %%i in ("%%a") do (
if "%%i" == "PartNumber" (
@echo 内存型号: %%b
set str=%%b
@echo 内存型号: !str:~0,-1!>>%name%txt
)
if "%%i" == "Capacity" (
@echo 内存大小: %%b
set str=%%b
@echo 内存大小: !str:~0,-1!>>%name%txt
)
)
)
@echo>>%name%txt
@echo
@rem 磁盘名称 磁盘型号 磁盘容量
for /f "tokens=1-2 delims==" %%a in ('wmic diskdrive get Caption^,Model^,Size /value') do (
for /f %%i in ("%%a") do (
if "%%i" == "Caption" (
@echo 磁盘名称: %%b
set str=%%b
@echo 磁盘名称: !str:~0,-1!>>%name%txt
)
if "%%i" == "Model" (
@echo 磁盘型号: %%b
set str=%%b
@echo 磁盘型号: !str:~0,-1!>>%name%txt
)
if "%%i" == "Size" (
@echo 磁盘容量: %%b
set str=%%b
@echo 磁盘容量: !str:~0,-1!>>%name%txt
)
)
)
@echo>>%name%txt
@echo
@rem 显卡名称
for /f "tokens=1-2 delims==" %%a in ('wmic path Win32_VideoController get Name /value') do (
for /f %%i in ("%%a") do (
if "%%i" == "Name" (
@echo 显卡名称: %%b
set str=%%b
@echo 显卡名称: !str:~0,-1!>>%name%txt
)
)
)
pause
internal static string GetCpuInfo()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\CIMV2", "SELECT FROM Win32_Processor");
foreach (ManagementObject obj2 in searcherGet())
{
try
{
return (obj2GetPropertyValue("Name")ToString() + "," + obj2GetPropertyValue("CurrentClockSpeed")ToString() + " Mhz," + EnvironmentProcessorCountToString() + " 个处理器");
}
catch
{
continue;
}
}
return "未知";
}
internal static string GetCpuID()
{
ManagementObjectCollection instances = new ManagementClass("Win32_Processor")GetInstances();
foreach (ManagementObject obj2 in instances)
{
return obj2Properties["ProcessorId"]ValueToString();
}
return null;
}
以上就是关于VB.Net (VB2010)怎么使用WMI来获取CPU型号全部的内容,包括:VB.Net (VB2010)怎么使用WMI来获取CPU型号、批处理之获取电脑配置信息、c#中如何获得 cpu型号等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)