当前位置: 移动技术网 > IT编程>脚本编程>Python > python定时检查启动某个exe程序适合检测exe是否挂了

python定时检查启动某个exe程序适合检测exe是否挂了

2019年04月04日  | 移动技术网IT编程  | 我要评论

有机滤膜,牛烽网,李智雅整容

详见代码如下:
复制代码 代码如下:

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:\shuaji\bin\main.exe'])
timer_start()
if __name__ == "__main__":
timer_start()
while true:
time.sleep(1)

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网