VBS判断某个进程存在与否?
发布网友
发布时间:2022-06-18 20:24
我来回答
共3个回答
热心网友
时间:2023-11-05 13:11
以百度hi进程为例:
'═════代═══码═══开═══始═════
on error resume next
set y=getobject("winmgmts:\\.\root\cimv2")
set ws=createobject("wscript.shell")
set x=y.execquery("select * from win32_process where name='BaiHi.exe'")
for each i in x
msgbox "BaiHi进程存在"
wscript.quit
next
msgbox "BaiHi进程不存在"
'═════代═══码═══结═══束═════
将其中的BaiHi替换为你要检测的进程名。
热心网友
时间:2023-11-05 13:11
以qq为例吧,嘻嘻.楼主如若要查询其它进程,请用那个进程的进程名替换掉下面出现qq.exe的地方
‘------------------------VBS团队-------------------------
dim obj
dim matches
set obj = getobject("winmgmts:")
set matches = obj.execquery("select * from win32_process")
for each match in matches
if lcase(match.name) = "qq.exe" then
msgbox "QQ正在运行。。。"
WScript.Quit
else
msgbox "QQ没有运行!"
WScript.Quit
End if
next
set obj = nothing
’------------------------VBS团队-------------------------
参考资料:m
热心网友
时间:2023-11-05 13:12
程序已经测试过 ok~
do
Set Of = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
dim OK,oShell
OK=False
set bag=getobject("winmgmts:\\.\root\cimv2")
set pipe=bag.execquery("select * from win32_process where name='notepad.exe'")
For Each id In pipe
OK = True
Next
If not OK Then
objShell.open("d:\")
end if
wscript.sleep 60000
loop