Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use VBS to create and delete monitoring process

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to use VBS to achieve monitoring process creation and deletion", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use VBS to achieve monitoring process creation and deletion" bar!

Monitor the creation of a process, and the temporary event consumer issues an alarm each time a new process is created.

1. Monitoring the creation of a process

The copy code is as follows:

StrComputer = "."

Set objWMIService = GetObject ("winmgmts:" _

& "{impersonationLevel=impersonate}!\" & strComputer & "\ root\ cimv2")

Set colMonitoredProcesses = objWMIService. _

ExecNotificationQuery ("select * from _ _ instancecreationevent" _

& "within 1 where TargetInstance isa 'Win32_Process'")

I = 0

Do While i = 0

Set objLatestProcess = colMonitoredProcesses.NextEvent

Wscript.Echo objLatestProcess.TargetInstance.Name

Loop

two。 Monitor the deletion of a process, and the temporary event consumer issues an alarm each time the process terminates.

The copy code is as follows:

StrComputer = "."

Set objWMIService = GetObject ("winmgmts:" _

& "{impersonationLevel=impersonate}!\" & strComputer & "\ root\ cimv2")

Set colMonitoredProcesses = objWMIService. _

ExecNotificationQuery ("select * from _ _ instancedeletionevent" _

& "within 1 where TargetInstance isa 'Win32_Process'")

I = 0

Do While i = 0

Set objLatestProcess = colMonitoredProcesses.NextEvent

Wscript.Echo objLatestProcess.TargetInstance.Name

Loop

3. Monitor the use of processors by processes

The copy code is as follows:

StrComputer = "."

Set objWMIService = GetObject ("winmgmts:" _

& "{impersonationLevel=impersonate}!\" & strComputer & "\ root\ cimv2")

Set colProcesses = objWMIService.ExecQuery _

("Select * from Win32_process")

For Each objProcess in colProcesses

SngProcessTime = (CSng (objProcess.KernelModeTime) + _

CSng (objProcess.UserModeTime)) / 10000000

Wscript

Thank you for your reading, the above is "how to use VBS to achieve monitoring process creation and deletion" content, after the study of this article, I believe you have a deeper understanding of how to use VBS to achieve monitoring process creation and deletion of this problem, the specific use also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report