NO3: luacom WMI monitor process create and close

Source: Internet
Author: User

Create and disable WMI monitoring in luacom. It's cool. Then open notepad.exe and close it to see the two rows of output.

Getting started with WMI

Package. cpath = [[c: \ Program Files \ Lua \ 5.1 \ clibs \?. DLL] require "luacom" strcomputer = "mycomputername" obw.miservice = luacom. GetObject ("winmgmts: {impersonationlevel = impersonate }! \\\\".. Strcomputer .. "\ Root \ cimv2") csink = luacom. createobject ("wbemscripting. swbemsink ") dsink = luacom. createobject ("wbemscripting. swbemsink ") csinkh = {} function csinkh: onobjectready (objobject, objasynccontext) print (" process create detected: ", objobject: targetinstance (): Name () endfunction csinkh: oncompleted (objobject, objasynccontext) print ("completed") enddsinkh ={} function dsinkh: equals (objobject, objasynccontext) print ("process Delete detected:", objobject: targetinstance (): name () endfunction dsinkh: oncompleted (objobject, objasynccontext) print ("completed") endobjwmiservice: execicationqueryqueryasync (dsink, "select * from _ instancedeletionevent within 1 where targetinstance ISA 'win32 _ process'") ob1_miservice: execicationicationqueryasync (csink, "select * from _ instancecreationevent within 1 where targetinstance ISA 'win32 _ process'") luacom. connect (csink, csinkh) luacom. connect (dsink, dsinkh) luacom. startmessageloop ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.