Solved

What is the vbscript command for memory usage?

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

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 52

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

937 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

6 Experts available now in Live!

Get 1:1 Help Now