手机
当前位置:查字典教程网 >脚本专栏 >python >python定时检查启动某个exe程序适合检测exe是否挂了
python定时检查启动某个exe程序适合检测exe是否挂了
摘要:详见代码如下:复制代码代码如下:importthreadingimporttimeimportosimportsubprocessdefge...

详见代码如下:

复制代码 代码如下:

import threading

import time

import os

import subprocess

def get_process_count(imagename):

p = os.popen('tasklist /FI "IMAGENAME eq %s"' % imagename)

return p.read().count(imagename)

def timer_start():

t = threading.Timer(120,watch_func,("is running..."))

t.start()

def watch_func(msg):

print "I'm watch_func,",msg

if get_process_count('main.exe') == 0 :

print subprocess.Popen([r'D:shuajibinmain.exe'])

timer_start()

if __name__ == "__main__":

timer_start()

while True:

time.sleep(1)

【python定时检查启动某个exe程序适合检测exe是否挂了】相关文章:

python 参数列表中的self 显式不等于冗余

python 判断一个进程是否存在

Python实现的几个常用排序算法实例

python基础教程之基本内置数据类型介绍

python聊天程序实例代码分享

python搭建简易服务器分析与实现

使用wxpython实现的一个简单图片浏览器实例

python 自动提交和抓取网页

python求素数示例分享

python设置检查点简单实现代码

精品推荐
分类导航