VBScript 監(jiān)控磁盤更改事件實現(xiàn)代碼

字號:


    這篇文章主要介紹了如何用vbs實現(xiàn)監(jiān)控磁盤更改事件,需要的朋友可以參考下
    代碼如下:
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colMonitoredEvents = objWMIService. _
    ExecNotificationQuery("Select * from Win32_VolumeChangeEvent")
    Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    Wscript.Echo objLatestEvent.DriveName
    Wscript.Echo objLatestEvent.EventType
    Wscript.Echo objLatestEvent.Time_Created
    Loop