Sample scripts


Operating System
   Services
       Monitor Changes in Service Status , WMI

' Monitor Changes in Service Status


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService. _
ExecNotificationQuery("Select * from __instancemodificationevent " _
& "within 30 where TargetInstance isa 'Win32_Service'")
i = 0

Do While i = 0
Set objService = colServices.NextEvent
If objService.TargetInstance.State <;>; _
objService.PreviousInstance.State Then
Wscript.Echo objService.TargetInstance.Name _
& " is " & objService.TargetInstance.State _
& ". The service previously was " & _
objService.PreviousInstance.State & "."
End If
Loop


VbsEdit includes all these samples!


This package includes VbsEdit 32-bit, VbsEdit 64-bit, HtaEdit 32-bit and HtaEdit 64-bit.
The evaluation version never expires.




Home  

Copyright © 2001-2016 Adersoft