달력

1

« 2025/1 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

getProcessNUM.vbs
arguement => Process1.exe,Process2.exe,Process3.exe......

Object : Process
Counter : NumberOfProcess
Instance : $Data/Property[@Name='ProcessName']$
Value : $Data/Property[@Name='PerfValue']$

--------------------------------------------------------------------------------------------------


Option Explicit
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_SUCCESS = 4

Dim intResponse, strProcess, bLogPerformanceEvent, bGenerateSuccessEvent, bLogPerformanceData
Dim oAPI, oArgs, cProcessResult, oMOMBag, sProcess, propertyBag, perfValue
Dim ProcessName
Set oArgs = WScript.Arguments
Set oAPI = CreateObject("MOM.ScriptAPI")
If oArgs.Count < 1 Then
Call oAPI.LogScriptEvent("getProcessNUM.vbs", 10101, EVENT_TYPE_ERROR, "getProcessNUM script was called with fewer than one arguement.")
WScript.Quit -1
End If

strProcess = Split(oArgs.Item(0), ",")
For Each sProcess In strProcess
getProcessNUM(sProcess)
Next
oAPI.ReturnItems

Sub getProcessNUM(ProcessName)
Set cProcessResult = GetObject("winmgmts://./root/cimv2").ExecQuery("SELECT * FROM Win32_Process WHERE name = '" & ProcessName & "'")
perfValue= 0.0
perfValue= cdbl(cProcessResult.count)
Set propertyBag = oAPI.CreatePropertyBag()
propertyBag.AddValue "ProcessName", ProcessName
propertyBag.AddValue "PerfValue", PerfValue
oAPI.AddItem(propertyBag)
Call oAPI.Return(propertyBag)
Set cProcessResult = Nothing
End Sub

:
Posted by 커널64