python 打开某个exe_python定时检查启动某个exe程序(如果exe挂了)
生活随笔
收集整理的這篇文章主要介紹了
python 打开某个exe_python定时检查启动某个exe程序(如果exe挂了)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
詳見代碼如下:
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)
分享到:
2013-01-10 22:32
瀏覽 630
評論
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的python 打开某个exe_python定时检查启动某个exe程序(如果exe挂了)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用qt的qtcore库怎么包含_Git
- 下一篇: byte java byte_详解jav