QTP的那些事 判斷程序是否存在

2021-09-22 08:43:17 字數 1182 閱讀 4085

**如下,以判斷ie程序是否存在為例:

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='iexplore.exe'")

foreach i in x

msgbox "ie程序存在"

wscript.quit

next

msgbox "ie程序不存在"

**如下,以qq程序是否存在為例:

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='qq.exe'")

foreach i in x

msgbox "發現qq程序"

ws.run "123.bat"

wscript.quit

next

msgbox "沒有qq程序"

ws.run "456.bat"

也可以採用如下額的方式:採用tasklist命令的方式'tasklist^|findstr /i "%dstpro%"'
dim

set"wscript.shell"

do"c:\a.vbs"

true

"tskill iexplore"

"c:\b.vbs"

true

"tskill iexplore"

"c:\c.vbs"

true

"tskill iexplore"

"c:\d.vbs"

true

"tskill iexplore"

loop

判斷子程序是否存在

if kill pidt,0 0 child process has dead.else child alive 前提條件是,父程序已經處理了sigchld.否則,此檢測方法將失效 unix 環境高階程式設計 的解釋為 kill pid t pid,int signo posix將編號為0的訊號定義...

python判斷程序是否存在

coding utf 8 import win32com.client def check exsit process name wmi win32com.client.getobject winmgmts processcodecov wmi.execquery select from win32...

C 判斷程序是否存在

判斷指定的程序或程式是否存在方法 一 判斷指定程式名的程序是否存在 view plain bool callback ipenumfunc hwnd hwnd,lparam lparam return 1 二 判斷指定程序名的程序是否存在 view plain dword getprocessidf...