VBS判断某个进程存在与否?
3个回答
展开全部
以百度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='BaiduHi.exe'")
for each i in x
msgbox "BaiduHi进程存在"
wscript.quit
next
msgbox "BaiduHi进程不存在"
'═════代═══码═══结═══束═════
将其中的BaiduHi替换为你要检测的进程名。
'═════代═══码═══开═══始═════
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='BaiduHi.exe'")
for each i in x
msgbox "BaiduHi进程存在"
wscript.quit
next
msgbox "BaiduHi进程不存在"
'═════代═══码═══结═══束═════
将其中的BaiduHi替换为你要检测的进程名。
展开全部
以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团队-------------------------
‘------------------------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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
程序已经测试过 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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询