获取同名进程的数量

2015-02-06 0 800
获取同名进程的数量
Option Explicit
Dim objWMIService, objProcess, colProcess, strComputer, processName, instances

strComputer = "."
instances = 0
processName = "wscript.exe" 

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

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")

For Each objProcess in colProcess
If objProcess.Name = processName Then instances = instances + 1
Next

If processName = "wscript.exe" Then 
	If instances = 1 Then
	WScript.Echo "There is no other VBScript running except this one!"
	Else
	WScript.Echo "There are currently " & "(" & instances & ") " & "VBScript" & " Instances running!"
	End If
Else
	WScript.Echo "There are currently " & "(" & instances & ") " & """" & processName & """" & " Instances running!"
End If

遇见资源网 ASP/Basic 获取同名进程的数量 http://www.ox520.com/13399.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务