Solved

What is the vbscript command for memory usage?

Posted on 2010-11-30
5
1,324 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 56

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 56

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

624 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