2008-09-18 82 views

回答

4
public static long GetCommitCharge() 
    { 
     var p = new System.Diagnostics.PerformanceCounter("Memory", "Committed Bytes"); 
     return p.RawValue; 
    } 
1

下面是一個使用WMI的例子:

strComputer = "." 

Set objSWbemServices = GetObject("winmgmts:\\" & strComputer) 
Set colSWbemObjectSet = _ 
objSWbemServices.InstancesOf("Win32_LogicalMemoryConfiguration") 

For Each objSWbemObject In colSWbemObjectSet 
Wscript.Echo "Total Physical Memory (kb): " & _ 
objSWbemObject.TotalPhysicalMemory 
WScript.Echo "Total Virtual Memory (kb): " & _ 
objSWbemObject.TotalVirtualMemory 
WScript.Echo "Total Page File Space (kb): " & _ 
objSWbemObject.TotalPageFileSpace 
Next 

如果運行CScript中這個腳本,你應該可以看到安裝在命令窗口中顯示在目標計算機上的物理內存的千字節數。下面是從腳本的典型輸出: 總的物理內存(KB):261676

編輯:包括總頁面文件的大小屬性還

摘自:http://www.microsoft.com/technet/scriptcenter/guide/sas_wmi_dieu.mspx?mfr=true

+0

我不認爲這表明Commit Charge的價值。這顯示安裝的總物理/虛擬內存,對嗎?編輯爲包含總頁面文件大小的 – Larsenal 2008-09-18 19:54:17

相關問題