*nix `free` 或 DOS `mem` 相当于 Windows 7 (64 位)

*nix `free` 或 DOS `mem` 相当于 Windows 7 (64 位)

*尼克斯系统,free显示系统中可用和已用内存的总量。根据我的研究,DOSmem命令类似,但在 64 位版本的 Windows 7 上不可用。该命令是否有内置替代方法mem

答案1

请注意,所有这些都返回千字节。

wmic方法

wmic os get TotalVisibleMemorySize,FreePhysicalMemory

我不确定 TotalVisibleMemorySize 是否正确,但它确实出现显示我的系统的物理内存。


VBScript 方法

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394587%28v=vs.85%29.aspx

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings 
    Wscript.Echo "Available Physical Memory: " & _
        objOperatingSystem.FreePhysicalMemory
Next

PowerShell 方法

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394587%28v=vs.85%29.aspx

# Get-FreeMemory.ps1
# Sample using PowerShell
# 1st sample from http://msdn.microsoft.com/en-us/library/aa394587
# Thomas Lee

$mem = Get-WmiObject -Class Win32_OperatingSystem

# Display memory
"System : {0}" -f $mem.csname
"Free Memory: {0}" -f $mem.FreePhysicalMemory

该脚本产生以下输出:

PS C:\foo> .\get-freememory.ps1
  System : COOKHAM8
  Free Memory: 2776988

PowerShell 精简版(从 cmd 调用)

powershell.exe -c (Get-WmiObject -Class Win32_OperatingSystem).FreePhysicalMemory

相关内容