VB/WMI help needed.

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
aux_con
Newbie
Posts: 7
Joined: Sat Sep 09, 2006 12:14 am

VB/WMI help needed.

Post by aux_con » Tue Oct 31, 2006 8:40 pm

So I'm not well versed in VB... but I'm trying to get a "footprint" script together that will snapshot my process vital statistics over time (CPU use and memory useage) using WMI. I've used the example to see if the process is running but how do I get to the statistics of the process itself.

I think I would need to get the colletion of a specific process... but this is where I get lost. :(

Any help is greatly appreciated. Also assume I know nothing about VB.


here's the script I use to see if the process (or any specified process) is running.

Assigned>PROCESS,processexists
if>processexists=FALSE
Let>PROCESS=AgentStation.exe
Endif

VBSTART
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function IsProcessRunning(ProcessName)
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = oWMIService.ExecQuery ("Select Name from Win32_Process where Name='" & ProcessName & "'")
IsProcessRunning = colProcessList.count
End Function
VBEND

VBEval>IsProcessRunning("%PROCESS%"),result

If result>0
Let>MACRO_RESULT=RUNNING
Macro>%SCRIPT_DIR%\ExpLog.scp /MESSAGE=%PROCESS% running! /STATE=INFO /CALLINGSCRIPT=%SCRIPT_FILE%
Else
Let>MACRO_RESULT=NOT FOUND
Macro>%SCRIPT_DIR%\ExpLog.scp /MESSAGE=%PROCESS% not found! /STATE=INFO /CALLINGSCRIPT=%SCRIPT_FILE%
Endif

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Tue Oct 31, 2006 9:01 pm

I'll look at your script a little later, but you should save this link:

http://computerperformance.co.uk/vbscri ... basics.htm

Good place to start with WMI...

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts