如何检查通过批处理脚本可用内存(RAM)? [英] How to check available memory (RAM) via batch script?

查看:528
本文介绍了如何检查通过批处理脚本可用内存(RAM)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我们如何可以检查批处理脚本可用内存?有没有什么方法已经可用?如果不是在批处理脚本可能那么有没有任何其他方式,我们可以得到的可用内存?

I would like to know that how we can check the available memory in batch script? Is there any method already available? If it is not possible in batch script then is there any other way by which we can get the memory available?

操作系统:Windows XP / Windows 7的

OS: Windows XP / Windows 7

推荐答案

该网站有一个检索的的内存量示例VBScript:

This site has a sample VBScript that retrieves the total amount of memory:

<一个href=\"http://www.computerperformance.co.uk/vbscript/wmi_memory.htm\">http://www.computerperformance.co.uk/vbscript/wmi_memory.htm

有可适于报告的存储器的可用量

It can be adapted to report the available amount of memory:

' Memory.vbs
' Sample VBScript to discover how much RAM in computer
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.3 - August 2010
' -------------------------------------------------------' 

Option Explicit
Dim objWMIService, perfData, entry 
Dim strLogonUser, strComputer 

strComputer = "." 

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _ 
& strComputer & "\root\cimv2") 
Set perfData = objWMIService.ExecQuery _
("Select * from Win32_PerfFormattedData_PerfOS_Memory") 

For Each entry in perfData 
Wscript.Echo "Available memory bytes: " & entry.AvailableBytes
Next

WScript.Quit

您可以通过将其保存与扩展名的文件运行 .VBS (如 memory.vbs )和用的Cscript.exe运行它,例如:

You can run it by saving it to a file with extension .vbs (e.g. memory.vbs) and running it with cscript.exe, e.g.:

cscript.exe //nologo memory.vbs

...要得到这样的输出:

...to get output like:

Available memory bytes: 4481511424

这篇关于如何检查通过批处理脚本可用内存(RAM)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆