Option Explicit Dim strComputer, objWMIService, colItems, objItem, ScriptCount strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 'Set colItems = objWMIService.ExecQuery("Select * from Win32_Process WHERE NAME = 'wscript.exe' or NAME = 'cscript.exe'") Set colItems = objWMIService.ExecQuery("Select * from Win32_Process WHERE NAME Like '%script.exe'") For Each objItem in colItems If UCase(Right(Trim(Replace(objItem.CommandLine, """", "")), Len(WScript.ScriptName))) = UCase(WScript.ScriptName) Then ScriptCount = ScriptCount + 1 If ScriptCount >= 2 Then WScript.Quit End If End If Next Dim FS, FlgFile, objFlgFile Set FS = WScript.CreateObject("Scripting.FileSystemObject") FlgFile = "x:\path\screensaver.flg" Call DeleteFlgFile() Dim objEventSource, objEventObject Set objEventSource = objWMIService.ExecNotificationQuery _ ("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_Process'") Do While True Set objEventObject = objEventSource.NextEvent() If Right(objEventObject.TargetInstance.Name, 4) = ".scr" Then Select Case objEventObject.Path_.Class Case "__InstanceCreationEvent" Call CreateFlgFile() Case "__InstanceDeletionEvent" Call DeleteFlgFile() End Select End If If CheckKiriExist() = 0 Then Exit Do Loop Call DeleteFlgFile() WScript.Quit Function CheckKiriExist() Set colItems = objWMIService.ExecQuery("Select * from Win32_Process WHERE NAME = 'kiri9.exe'") CheckKiriExist = colItems.Count End Function Sub CreateFlgFile() Set objFlgFile = FS.CreateTextFile(FlgFile) objFlgFile.Close End Sub Sub DeleteFlgFile() If FS.FileExists(FlgFile) = True Then FS.DeleteFile FlgFile, True End If End Sub