恭喜,你发布的帖子
发布于 2018-08-15 21:47:21
3楼
你可以判断当前是否打开了excel进程,如果打开了直接关闭,用taskkill指令
下面是例子代码:
dim wmi,proc,procs,proname,flag,WshShell
proname="QQ.exe" '需要监测的务进程的名称
set wmi=getobject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2")
set procs=wmi.execquery("select * from win32_process")
flag=False
for each proc in procs
if strcomp(proc.name,proname)=0 then
flag=true
exit for
end if
next
set wmi=nothing
if flag then
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run "taskkill /f /im " & proname,0
MsgBox "进程已经结束!"
WScript.Quit
Else
MsgBox "未找到进程!"
WScript.Quit
end if
请填写推广理由:
分享
只看
楼主