Option Explicit
Dim objWMIService,colProcessList,strComputer
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'excel.exe'")
If colProcessList.Count>0 Then
MsgBox "检测到EXCEL程序运行中,程序退出!"
WScript.Quit
End If
Set colProcessList = Nothing
Set objWMIService = Nothing
WScript.Quit