Solved

What is the vbscript command for memory usage?

Posted on 2010-11-30
5
1,287 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:
jmatix earned 167 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 51

Assisted Solution

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

Assisted Solution

by:ScottsdaleJay
ScottsdaleJay earned 166 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 51

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Welcome to part one of a multi-part tutorial series, VBScript for Windows System Administrators.  The goal of this series is to teach non-programmers how to write useful VBS code to automate their environment, and perform tasks faster, and in a more…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now