获取物理内存

获取物理内存

用最少的努力来收集我们 500 多台 Windows(XP 和 7)机器中每台机器的 RAM 容量的首选方法是什么?

答案1

我会提供两个选择:

  1. Microsoft 评估和规划 (MAP) 工具包(免费)
  2. Windows 的系统信息(需要购买许可证和脚本;我使用它来确定大约 50 台 PC 中有哪些 RAM(以及有多少个插槽),方法是通过 PSEXEC 在网络中的所有系统上运行它。然后,对结果数据进行简单的 FIND 命令,就可以清楚地告诉我所有我需要知道的信息。

不过,由于您的问题是最不需要费力回答的,我可能会说 MAP。

答案2

我收集这些信息(以及更多)作为登录脚本的一部分。每个日志(每台机器一个,每个用户一个)稍后都会被解析,并将信息存储在数据库中。我从某个早已被遗忘的来源复制的(VBS)脚本的相关部分是:

'// Memory Info
objHardwareFile.WriteLine "Memory Information:"
objHardwareFile.WriteLine "==================="
For Each objMem In GetObject("winmgmts:{impersonationLevel=impersonate}\\.\root\cimv2").InstancesOf("Win32_PhysicalMemory")
Select Case objMem.MemoryType
    Case 0
        rtype = "Unknown"
    Case 1
        rtype = "Other"
    Case 2
        rtype = "DRAM"
    Case 3
        rtype = "Synchronous DRAM"
    Case 4
        rtype = "Cache DRAM"
    Case 5
        rtype = "EDO"
    Case 6
        rtype = "EDRAM"
    Case 7
        rtype = "VRAM"
    Case 8
        rtype = "SRAM"
    Case 9
        rtype = "RAM"
    Case 10
        rtype = "ROM"
    Case 11
        rtype = "Flash"
    Case 12
        rtype = "EEPROM"
    Case 13
        rtype = "FEPROM"
    Case 14
        rtype = "EPROM"
    Case 15
        rtype = "CDRAM"
    Case 16
        rtype = "3DRAM"
    Case 17
        rtype = "SDRAM"
    Case 18
        rtype = "SGRAM"
    Case 19
        rtype = "RDRAM"
    Case 20
        rtype = "DDR"
End Select
objHardwareFile.WriteLine " Memory Bank: " &  objMem.BankLabel
objHardwareFile.WriteLine " Memory Size: " & objMem.Capacity/1024/1024 & " MB"
objHardwareFile.WriteLine " Memory Speed: " & objMem.Speed & " MHZ"
objHardwareFile.WriteLine " Memory Type: " & rtype
next

相关内容