Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

What is the vbscript command for memory usage?

Posted on 2010-11-30
5
Medium Priority
?
1,407 Views
Last Modified: 2012-06-27
What is the vbscript command for memory usage? I presume its something like memusage.vbs. I have a batch file that collects the iis process id's on a web server and writes to a text file. I need memory usage of each process to identify which is causing a problem.
0
Comment
Question by:Choakem
5 Comments
 
LVL 16

Accepted Solution

by:
Justin Mathews earned 668 total points
ID: 34241433
You can use WMI to get a peek into memory usage stats. See sample below. For a more extensive sample go to:

http://www.activexperts.com/admin/scripts/wmi/vbscript/0191/

Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Memory") 

strLinePercentCommittedBytesInUse = ""
For Each objItem In colItems 
	strLinePercentCommittedBytesInUse = strLinePercentCommittedBytesInUse & " " & objItem.PercentCommittedBytesInUse
Next

WScript.Echo "Used Mem % =" & strLinePercentCommittedBytesInUse

Open in new window

0
 
LVL 59

Assisted Solution

by:Bill Prew
Bill Prew earned 668 total points
ID: 34241811
0
 

Assisted Solution

by:ScottsdaleJay
ScottsdaleJay earned 664 total points
ID: 34242460
You could also use the System.Diagnostics object:

        Dim CpuInfo As System.Diagnostics.PerformanceCounter
        Dim MemInfo As System.Diagnostics.PerformanceCounter

        Dim Cpu As Single
        Dim Mem As Single

        CpuInfo = New System.Diagnostics.PerformanceCounter()
        CpuInfo.CategoryName = "Processor"
        CpuInfo.CounterName = "% Processor Time"
        CpuInfo.InstanceName = "_Total"

        MemInfo = New System.Diagnostics.PerformanceCounter("Memory", "Available MBytes")

        Cpu = CpuInfo.NextValue
        Mem = MemInfo.NextValue
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 34243133
==> ScottsdaleJay,

I don't think that will work as a VBS script, will it?

~bp
0
 
LVL 1

Author Closing Comment

by:Choakem
ID: 34401566
My friend asked this question and I honestly dont know which was the best answer so I will award points to you all. Thanks for taking the time to respond.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Screencast - Getting to Know the Pipeline
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question