在*尼克斯系統,free
顯示系統中可用和已使用記憶體的總量。根據我的研究,DOS命令類似mem
,但它在 64 位元版本的 Windows 7 上不可用。mem
答案1
請注意,所有這些都返回千字節。
wmic
方法
wmic os get TotalVisibleMemorySize,FreePhysicalMemory
我不確定 TotalVisibleMemorySize 是否正確,但確實如此出現顯示我係統上的實體記憶體。
VB腳本方法
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