Solved

What is the vbscript command for memory usage?

Posted on 2010-11-30
5
1,294 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 54

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 54

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 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