dim strcomputer as string
dim objwmiservice as object
dim colprocesslist
dim objprocess as object
on error resume next
strcomputer = "."
set objwmiservice = getobject("winmgmts:" _
& "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2")
' strprocess = "excel.exe"
set colprocesslist = objwmiservice.execquery _
("select * from win32_process where name = '" & strprocess & "'")
for each objprocess in colprocesslist
objprocess.terminate
next
end sub
'********************************************************************************************
未解决的问题:由于绕不开同步执行函数中的doevens,timer总是不会溢出
积极思考中。。用脑用脑,发功。。。~~~~~
附同步执行程序:
sub shellwait(scommandline as string) '等到外部程序执行完成
dim hshell as long, hproc as long, lexit as long
hshell = shell(scommandline, vbhide)
hproc = openprocess(&h400, false, hshell)
do
getexitcodeprocess hproc, lexit
doevents
loop while lexit = &h103
end sub