Monitoring Core Process...
strComputer = "."
Const EVENT_SUCCESS=0
Const EVENT_ERROR=1
Const EVENT_WARNING=2
Const EVENT_INFORMATION=4
Const EVENT_AUDIT_SUCCESS=8
Const EVENT_AUDIT_FAILURE=16
'On Error Resume Next
Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2")
Set objShell = CreateObject("Wscript.Shell")
Const ForReading = 1
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("input.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
objDictionary.Add i, strNextLine
i = i + 1
loop
For Each objItem in objDictionary
strLine = objDictionary.Item(objItem)
strSplit=Split(strLine)
'pDimCount=2
'pName="notepad.exe"
pName=strSplit(0)
pDimCount=strSplit(1)+0
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = '"&pName&"'")
If colProcesses.Count < pDimCount Then
If Not objFSO.Fileexists(pName) Then
Set f1= objFSO.Createtextfile(pName, true)
Call EventLogingError(pDimCount,colProcesses.Count,pName)
End If
Else
If objFSO.Fileexists(pName) Then
set f2 = objFSO.getfile(pName)
f2.delete
Call EventLogingSuccess(pDimCount,colProcesses.Count,pName)
End If
End If
Next
Function EventLogingError(pDimCount,pCount,pName)
Set objShell = CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_ERROR, _
"There are less than "&pDimCount&" (Only exist "&pCount&" ) instances of "&pName&" running"
End Function
Function EventLogingSuccess(pDimCount,pCount,pName)
Set objShell = CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_SUCCESS, _
"There are "&pCount&"/"&pDimCount&" instances of "&pName&" running"
End Function
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12262773/viewspace-1048921/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- STREAMS MONITORING
- Column Monitoring
- Oracle:TABLE MONITORINGOracle
- oracle index monitoringOracleIndex
- Monitoring WebSite StateWeb
- Oracle EBS Monitoring ScriptsOracle
- Monitoring an SAP instance
- sql monitoring實驗SQL
- Monitoring Open and Cached Cursors
- Monitoring RMAN Backups
- Go: sysmon, Runtime MonitoringGo
- Oracle Real Time SQL MonitoringOracleSQL
- Monitoring Open and Cached Cursors(zt)
- Oracle9i Table monitoring 及10g table預設monitoring屬性Oracle
- PostgreSQL DBA(77) - Locks(Lock Monitoring)SQL
- 對索引開啟monitoring方法索引
- Top DBA Shell Scripts for Monitoring the DatabaseDatabase
- Monitoring Open and Cached Cursors(轉載)
- Java Monitoring, Management and Troubleshooting ToolsJava
- Create a trigger TO monitoring DDL
- Monitoring Tempdb in SQL Server 2005SQLServer
- PostgreSQL DBA(189) - PG 14 Monitoring ImprovementsSQL
- Oracle Streams STRMMON Monitoring Utility [ID 290605.1]Oracle
- RMAN: Monitoring Recovery Manager Jobs [ID 144640.1]
- Nagios is a system and network monitoring applicationiOSAPP
- Oracle 10g DML Table Monitoring ChangesOracle 10g
- Linux Performance Monitoring and Tuning IntroductionLinuxORM
- exec dbms_stats.FLUSH_DATABASE_MONITORING_INFO;Database
- godaddy 的 Monitoring performance to make your website fasterGoORMWebAST
- PyTorch出現:RuntimeError: An attempt has been made to start a new process...報錯 (已解決)PyTorchError
- PostgreSQL DBA(142) - PG 12(Monitoring PostgreSQL VACUUM processes)SQL
- Design and implementation of database anomaly monitoring system based on AI algorithmDatabaseAIGo
- SAP EEM End-User Experience Monitoring Central Note
- 使用Percona Monitoring Plugins模板監控MySQLPluginMySql
- Linux File System Change Monitoring Technology、Notifier TechnologyLinux
- 用IBM Tivoli Monitoring 監視Q 複製IBM
- 表變化的monitoring 及引數 statistics_level
- Oracle10g New Feature -- 7. Rollback MonitoringOracle