vbs查询系统信息(名称,版本,系统盘,32or64)-wmi

Function X86orX64()   
    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)    
    For Each objItem in colItems
		
       If InStr(objItem.SystemType, "64") <> 0 Then
            X86orX64 = "x64"       
        Else
           X86orX64 = "x86"
        End If
    Next
    
End Function

Function showOsInfo()   
    Dim res
    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
    res ="infoStart"
    For Each objItem in colItems
		res =res & "_" &  objItem.Caption		
		res =res & "_" &  objItem.SystemDrive
		res =res & "_" &  objItem.Version
		'WScript.Echo objItem.OSArchitecture       
    Next
    
	res =res & "_" & X86orX64()   
	res =res & "_infoEnd"
	WScript.Echo res
End Function
call showOsInfo()
WScript.Echo "complete!"

你可能感兴趣的:(vbs,wmi,系统信息)