zoukankan      html  css  js  c++  java
  • QTP的那些事判断进程是否存在

    代码如下,以判断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'")
    for each 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'") 
    for each i in x
    msgbox "发现qq进程"
    ws.run "123.bat"
    wscript.quit
    next
    msgbox "没有qq进程"
    ws.run "456.bat" 
     
    也可以采用如下额的方式:采用tasklist命令的方式'tasklist^|findstr /i "%DstPro%"'
    Dim objws
    Set objws=WScript.CreateObject("wscript.shell")
    Do
     objws.Run "c:\a.vbs",,True
     WScript.Sleep 3000
     objws.Run "tskill iexplore"
     objws.Run "c:\b.vbs",,True
     WScript.Sleep 3000
     objws.Run "tskill iexplore"
     objws.Run "c:\c.vbs",,True
     WScript.Sleep 3000
     objws.Run "tskill iexplore"
     objws.Run "c:\d.vbs",,True
     WScript.Sleep 3000
     objws.Run "tskill iexplore"
    Loop 

    作者:高级测试开发网
    博客地址:https://seniortesting.club
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    std thread
    windows更新包发布地址
    How to set up logging level for Spark application in IntelliJ IDEA?
    spark 错误 How to set heap size in spark within the Eclipse environment?
    hadoop 常用命令
    windows 安装hadoop 3.2.1
    windows JAVA_HOME 路径有空格,执行软连接
    day01MyBatisPlus条件构造器(04)
    day01MyBatisPlus的CRUD 接口(03)
    day01MyBatisPlus入门(02)
  • 原文地址:https://www.cnblogs.com/seniortestingdev/p/2352435.html
Copyright © 2011-2022 走看看